Actions
Bug #17193
closedEndless method definition doesn't work with lambdas in IRB
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.0.0preview1 (2020-09-25 master 0096d2b895) [x86_64-darwin19]
Description
Endless method definition doesn't work with lambdas. Please check the attached screenshot.
def foo() = 123
# => :foo
foo
# => 123
def bar() = lambda { |x| x * x }
# I expected the method to be defined.
def bar() = ->(x) { x * x }
# Same issue.
Nice to have:
def bar = lambda { |x| x * x }
def bar = ->(x) { x * x }
Files
Updated by wanabe (_ wanabe) over 4 years ago
I think this is an irb problem, not a ruby problem.
$ ruby -ve 'def bar() = lambda { |x| x * x };p bar'
ruby 3.0.0dev (2020-09-25T22:52:04Z master 137fa5b27e) [x86_64-linux]
#<Proc:0x00005582978039e0 -e:1 (lambda)>
Updated by kodnin (David Boot) over 4 years ago
wanabe (_ wanabe) wrote in #note-1:
I think this is an irb problem, not a ruby problem.
$ ruby -ve 'def bar() = lambda { |x| x * x };p bar' ruby 3.0.0dev (2020-09-25T22:52:04Z master 137fa5b27e) [x86_64-linux] #<Proc:0x00005582978039e0 -e:1 (lambda)>
I can confirm that this works indeed.
$ ruby -e 'def bar() = ->(x) { x * x }; puts bar.(3)'
9
Updated by mame (Yusuke Endoh) over 4 years ago
- Subject changed from Endless method definition doesn't work with lambdas to Endless method definition doesn't work with lambdas in IRB
Updated by taiyoslime (Taiyo Mizuhashi) about 4 years ago
This seems to be fixed in https://github.com/ruby/irb/pull/131. Please check it out.
Updated by aycabta (aycabta .) almost 4 years ago
- Status changed from Open to Closed
As @taiyoslime said, I confirmed that it was fixed in https://github.com/ruby/irb/pull/131.
Actions
Like0
Like0Like0Like0Like0Like0