Wrong example code in method-proc
Closed this issue · 1 comments
carlzhc commented
In https://github.com/rubyreferences/rubyref/blob/master/builtin/core/method-proc.md,
Lambda semantics is typically preserved during the proc lifetime, including &-deconstruction to a block of code:
p = proc {|x, y| x }
l = lambda {|x, y| x }
[[1, 2], [3, 4]].map(&p) #=> [1, 2]
[[1, 2], [3, 4]].map(&l) # ArgumentError: wrong number of arguments (given 1, expected 2)
The [[1, 2], [3, 4]].map(&p) #=> [1, 2]
should be [[1, 2], [3, 4]].map(&p) #=> [1, 3]
Conversion of other objects to procs
Any object that implements the to_proc method can be converted into a proc by the & operator, and therefore con be consumed by iterators.
con
should be can