Project

General

Profile

Actions

Bug #16414

closed

Incompatible behavior of Proc/lambda with single argument when using `Enumerator::Lazy#with_index`

Added by tomog105 (Tomohiro Ogoke) almost 5 years ago. Updated almost 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.0dev (2019-12-10T10:12:21Z master af11efd377) [x86_64-darwin18]
[ruby-core:96186]

Description

The following code raised an error wrong number of arguments (given 1, expected 2) (ArgumentError) in master.

$ ruby -e 'lambda = -> (s, i) { "#{i}:#{s}" }; p %w(a b c).each.lazy.with_index.map(&lambda).first(2)'
# expected result => ["0:a", "1:b"]

This code is valid up till Ruby 2.6.5 and 2.7.0-preview1, but it raised the error in Ruby 2.7.0-preview2 or later. Maybe, this behavior has been there since the implementation of Enumerator::Lazy#with_index.

Is this behaviour intended?

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0