Project

General

Profile

Actions

Bug #2776

closed

can't return from lambda with outer block

Added by wanabe (_ wanabe) almost 15 years ago. Updated over 13 years ago.

Status:
Rejected
Target version:
ruby -v:
ruby 1.9.2dev (2010-02-21 trunk 26722) [i686-linux]
Backport:
[ruby-dev:40453]

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


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #1018: return in an eigenclass definitionClosedko1 (Koichi Sasada)01/16/2009Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0