I just got the svn trunk and was testing some new stuff, but could not
find the define_singleton_method:
irb(main):001:0> [RUBY_VERSION,RUBY_RELEASE_DATE]
=> ["1.9.0", "2007-08-28"]
irb(main):002:0> a = ""
=> ""
irb(main):003:0> a.define_singleton_method(:foo){|x| x + 1}
NoMethodError: undefined method `define_singleton_method' for "":String
Running out of irc the same two lines above I get the same results:
[taq@~/code/ruby/1.9]ruby1.9 dsm.rb
dsm.rb:2:in `method_missing': undefined method `define_singleton_method'
for "":String (NoMethodError)
from dsm.rb:2:in `<main>'
Am I missing something?
Thanks!
on 29.08.2007 06:28
on 29.08.2007 09:45
Hi, At Wed, 29 Aug 2007 13:28:24 +0900, =?utf-8?Q?Eust=c3=a1quio_Rangel?= wrote in [ruby-talk:266637]: > I just got the svn trunk and was testing some new stuff, but could not > find the define_singleton_method: No such method is defined.
on 29.08.2007 12:26
Nobuyoshi Nakada wrote: > No such method is defined. Thanks for your answer, but now I'm kind of lost here. There's a reference of the method here: http://www.ruby-doc.org/core-1.9/classes/Object.html#M000330 And here, where I got the previous samples: http://eigenclass.org/hiki.rb?Changes+in+Ruby+1.9#l29 And also on the Changelog, from Matz!: Mon Oct 9 01:56:34 2006 Yukihiro Matsumoto <matz@ruby-lang.org> * eval.c (rb_obj_define_method): add new method Kernel#define_singleton_method. [ruby-list:42851] I got the latest trunk using: svn co http://svn.ruby-lang.org/repos/ruby/trunk ruby I searched for rb_obj_define_method on the C code but could not find any code for it. Searching for rb_define_singleton_method returns me a lot of references of its internal use (as C code) and its definition on class.c, but not as a method we can reach from the language, without a thing like 'rb_define_method(rb_mKernel, "define_singleton_method", rb_obj_instance_eval, -1);' there. So, I'm lost, what happened with this method? :-) Thanks again!
on 30.08.2007 07:08
Hi, At Wed, 29 Aug 2007 19:26:39 +0900, =?utf-8?Q?Eust=c3=a1quio_Rangel?= wrote in [ruby-talk:266659]: > And also on the Changelog, from Matz!: > Mon Oct 9 01:56:34 2006 Yukihiro Matsumoto <matz@ruby-lang.org> > > * eval.c (rb_obj_define_method): add new method > Kernel#define_singleton_method. [ruby-list:42851] It seems lost at YARV merger. Reverted now.
on 30.08.2007 20:59
Nobuyoshi Nakada wrote:
> It seems lost at YARV merger. Reverted now.
Thank you!