Project

General

Profile

Actions

Bug #16406

closed

`(lambda_proc << normal_proc).lambda?` should return false

Added by alanwu (Alan Wu) over 4 years ago. Updated over 3 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]
[ruby-core:96139]
Tags:

Description

Consider:

plus = proc { |a, b| a + b }
mult_two = ->(x) { x * 2 }
composed = mult_two << plus
p [composed. lambda?, composed.call([1, 2])]

I think this ought to print [false, 6] instead of [true, 6], as the call composed.call([1, 2]) is clearly not using lambda semantics.
Since composed = f << g calls g first, I think it makes sense to report #lambda? base on whether g has lambda semantics.
I have a pull request at https://github.com/ruby/ruby/pull/2729 to make this change.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0