[#92063] [Ruby trunk Misc#15723] Reconsider numbered parameters — zverok.offline@...
SXNzdWUgIzE1NzIzIGhhcyBiZWVuIHVwZGF0ZWQgYnkgenZlcm9rIChWaWN0b3IgU2hlcGVsZXYp
3 messages
2019/03/31
[ruby-core:91881] [Ruby trunk Bug#15708] Implicit numbered argument decomposes an array
From:
hsbt@...
Date:
2019-03-19 23:14:17 UTC
List:
ruby-core #91881
Issue #15708 has been updated by hsbt (Hiroshi SHIBATA).
Sorry, your inconvenience experience. We have an issue of bugs.ruby-lang.org. I fixed it on this morning(JST).
I removed duplicated issues and copy from them.
@nobu said:
Intended.
It equals
```ruby
a.map{|x,| x} # => [1, 2, 3]
```
----------------------------------------
Bug #15708: Implicit numbered argument decomposes an array
https://bugs.ruby-lang.org/issues/15708#change-77202
* Author: sawa (Tsuyoshi Sawada)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: 2.7.0dev
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
In the following, `@1` refers to the entire item iterated:
```ruby
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|`:
```ruby
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?
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>