Actions
Bug #2776
closedcan't return from lambda with outer block
Description
=begin
http://pc12.2ch.net/test/read.cgi/tech/1264635554/685 で質問されていたのですが
1.8 と 1.9 で lambda の挙動が異なっています。
test.rb¶
class Foo
def initialize(&func)
@func = lambda(&func)
end
def bar(x)
@func.call(x)
end
end
foo = Foo.new{ |x| return x**2 }
p foo.bar(2)
$ ruby1.8 -v test.rb
ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
4
$ ./ruby -v test.rb
ruby 1.9.2dev (2010-02-21 trunk 26722) [i686-linux]
test.rb:9:in block in <main>': unexpected return (LocalJumpError) from test.rb:6:in
call'
from test.rb:6:in bar' from test.rb:10:in
'
=end
Actions
Like0
Like0Like0Like0Like0