ruby-changes:31333
From: zzak <ko1@a...>
Date: Thu, 24 Oct 2013 12:49:00 +0900 (JST)
Subject: [ruby-changes:31333] zzak:r43412 (trunk): * object.c: [DOC] Document first argument also takes string for:
zzak 2013-10-24 12:48:54 +0900 (Thu, 24 Oct 2013) New Revision: 43412 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43412 Log: * 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 Modified files: trunk/ChangeLog trunk/object.c Index: ChangeLog =================================================================== --- ChangeLog (revision 43411) +++ ChangeLog (revision 43412) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Oct 24 12:45:53 2013 Zachary Scott <e@z...> + + * 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 + Thu Oct 24 12:23:58 2013 KOSAKI Motohiro <kosaki.motohiro@g...> * thread.c (rb_thread_terminate_all): add a comment why we need Index: object.c =================================================================== --- object.c (revision 43411) +++ object.c (revision 43412) @@ -2034,6 +2034,12 @@ rb_mod_attr_accessor(int argc, VALUE *ar https://github.com/ruby/ruby/blob/trunk/object.c#L2034 * * 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, https://github.com/ruby/ruby/blob/trunk/object.c#L2142 /* * 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, https://github.com/ruby/ruby/blob/trunk/object.c#L2150 * * 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, https://github.com/ruby/ruby/blob/trunk/object.c#L2169 /* * 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, https://github.com/ruby/ruby/blob/trunk/object.c#L2180 * 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/