Project

General

Profile

Actions

Bug #15708

closed

Implicit numbered argument decomposes an array

Added by sawa (Tsuyoshi Sawada) over 5 years ago. Updated over 5 years ago.

Status:
Rejected
Target version:
-

Description

In the following, @1 refers to the entire item iterated:

a = [1, 2, 3]
a.map{|x| x} # => [1, 2, 3]
a.map{@1} # => [1, 2, 3]

whereas in the following, @1 refers to the first item achieved by decomposing the item iterated, behaving the same as x given by |(x)| rather than by |x|:

a = [[1], [2], [3]]
a.map{|x| x} # => [[1], [2], [3]]
a.map{|(x)| x} # => [1, 2, 3]
a.map{@1} # => [1, 2, 3]

Is this intended?


Files

single-implicit-arg-no-destructure.diff (471 Bytes) single-implicit-arg-no-destructure.diff jeremyevans0 (Jeremy Evans), 04/11/2019 09:34 PM

Related issues 2 (0 open2 closed)

Related to Ruby master - Misc #15723: Reconsider numbered parametersFeedbackmatz (Yukihiro Matsumoto)Actions
Related to Ruby master - Bug #16178: Numbered parameters: _1 should be the same as |x| and _0 should not existClosedmatz (Yukihiro Matsumoto)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0