[#97678] [Ruby master Feature#16752] :private param for const_set — bughitgithub@...
Issue #16752 has been reported by bughit (bug hit).
5 messages
2020/04/02
[ruby-core:97665] [Ruby master Bug#16748] Different behaviour between a hash and multi-Array when passing 2 arguments to a proc
From:
mnash@...
Date:
2020-04-01 17:49:40 UTC
List:
ruby-core #97665
Issue #16748 has been updated by Mattruby (Matthew Nash).
mame (Yusuke Endoh) wrote in #note-3:
> The behavior of 2.5.5 was wrong. `Array#map` yields each element, in this case, `['one', 'two']`, an array of two elements. The lambda requires two arguments, but one array is passed, which should raise "wrong number of arguments".
>
> You may want to use `-> (ary) { ary[0] }` instead of `-> (one, two) { one }`. Or you can use `proc {|one, two| one }`.
Ok, the strange thing is it works for a Hash, and i assumed that map treats hashes and multi dimensional arrays in the same way.
Thanks though
----------------------------------------
Bug #16748: Different behaviour between a hash and multi-Array when passing 2 arguments to a proc
https://bugs.ruby-lang.org/issues/16748#change-84872
* Author: Mattruby (Matthew Nash)
* Status: Rejected
* Priority: Normal
* ruby -v: 2.7.0
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
In Ruby 2.5.5 i get what i'm expecting
```ruby
test = -> (one, two) { one }
[['one', 'two']].map(&test)
=> ["one"]
```
In Ruby 2.7.0 this doesn't work
```ruby
test = -> (one, two) { one }
[['one', 'two']].map(&test)
wrong number of arguments (given 1, expected 2) (ArgumentError)
```
---Files--------------------------------
Screen Shot 2020-04-01 at 16.47.37.png (205 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>