rubyreferences/rubyref

Wrong example code in method-proc

Closed this issue · 1 comments

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

This documentation is lifted directly from Ruby’s core class docs; and Ruby Reference was rendered from the core docs at a Ruby 2.7 time.

Both problems were already fixed in the core Proc docs