From: Mark Hubbart Date: 2005-05-05T01:17:55+09:00 Subject: Re: Bug or on purpose? On 5/4/05, Robert Klemme wrote: > Joao Pedrosa wrote: > > Hi, > > > > dewd@heaven:~ $ ruby -v > > ruby 1.9.0 (2005-05-01) [i686-linux] > > dewd@heaven:~ $ irb > > irb(main):001:0> def opa s > > irb(main):002:1> 'z' > > irb(main):003:1> end > > => nil > > irb(main):004:0> opa 'kct' > > => "z" > > irb(main):005:0> opa = opa('kct') > > NoMethodError: undefined method `call' for nil:NilClass > > from (irb):5 > > irb(main):006:0> exit > > dewd@heaven:~ $ > > > > I tested it on Windows and on Linux with Ruby CVS-HEAD: > > dewd@heaven:~ $ ruby -v > > ruby 1.9.0 (2005-05-01) [i686-linux] > > > > Is it on purpose? Because it breaks some code in at least a lib that I > > know of (in rakewx.rb from wxRuby). > > Dunno... > > Additional note: 1.8.2 doesn't show this behavior. But: never trust IRB > when it comes to local variables. Did you also try that in a script or > with ruby -e '...'? This looks like it may be the result of a bug in the new proc calling feature. If I understand correctly, it translates foo(something) into foo.call(something) where foo is a local variable. And since "opa" becomes a local variable in that line, it tries to call it, and finds it to be nil. I think. cheers, Mark