aboutsummaryrefslogtreecommitdiffstats
path: root/object.c
diff options
context:
space:
mode:
authorzzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-24 03:48:54 +0000
committerzzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-24 03:48:54 +0000
commitec9ec2643085486afacc268e330e4a595f898e4b (patch)
treef12185a246fbb2dbdafc3bea5ef25c78eba44441 /object.c
parent61430a167b3f562ffbaeb3bbbf68d33b907881d0 (diff)
downloadruby-ec9ec2643085486afacc268e330e4a595f898e4b.tar.gz
* object.c: [DOC] Document first argument also takes string for:
rb_mod_const_get, rb_mod_const_set, rb_mod_const_defined Also added note about NameError exception for invalid constant name git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/object.c b/object.c
index 6b87c8d705..c52916b3bc 100644
--- a/object.c
+++ b/object.c
@@ -2034,6 +2034,12 @@ rb_mod_attr_accessor(int argc, VALUE *argv, VALUE klass)
*
* Object.const_get 'Foo::Baz::VAL' # => 10
* Object.const_get 'Foo::Baz::VAL', false # => NameError
+ *
+ * If neither +sym+ nor +str+ is not a valid constant name a NameError will be
+ * raised with a warning "wrong constant name".
+ *
+ * Object.const_get 'foobar' #=> NameError: wrong constant name foobar
+ *
*/
static VALUE
@@ -2136,6 +2142,7 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
/*
* call-seq:
* mod.const_set(sym, obj) -> obj
+ * mod.const_set(str, obj) -> obj
*
* Sets the named constant to the given object, returning that object.
* Creates a new constant if no constant with the given name previously
@@ -2143,6 +2150,12 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
*
* Math.const_set("HIGH_SCHOOL_PI", 22.0/7.0) #=> 3.14285714285714
* Math::HIGH_SCHOOL_PI - Math::PI #=> 0.00126448926734968
+ *
+ * If neither +sym+ nor +str+ is not a valid constant name a NameError will be
+ * raised with a warning "wrong constant name".
+ *
+ * Object.const_set('foobar', 42) #=> NameError: wrong constant name foobar
+ *
*/
static VALUE
@@ -2156,6 +2169,7 @@ rb_mod_const_set(VALUE mod, VALUE name, VALUE value)
/*
* call-seq:
* mod.const_defined?(sym, inherit=true) -> true or false
+ * mod.const_defined?(str, inherit=true) -> true or false
*
* Checks for a constant with the given name in <i>mod</i>
* If +inherit+ is set, the lookup will also search
@@ -2166,6 +2180,12 @@ rb_mod_const_set(VALUE mod, VALUE name, VALUE value)
* Math.const_defined? "PI" #=> true
* IO.const_defined? :SYNC #=> true
* IO.const_defined? :SYNC, false #=> false
+ *
+ * If neither +sym+ nor +str+ is not a valid constant name a NameError will be
+ * raised with a warning "wrong constant name".
+ *
+ * Hash.const_defined? 'foobar' #=> NameError: wrong constant name foobar
+ *
*/
static VALUE