diff options
author | Akinori MUSHA <knu@idaemons.org> | 2022-12-21 18:19:19 +0900 |
---|---|---|
committer | Akinori MUSHA <knu@idaemons.org> | 2022-12-21 18:19:19 +0900 |
commit | 308ccbaeb2c1c0e78d59c0411ddbeede8d2324f0 (patch) | |
tree | 13b386470281b15138139cd48c033feb213e5d75 /tool | |
parent | 684fa46ee68dd7f1f07d4f7f65861d6875736122 (diff) | |
download | ruby-308ccbaeb2c1c0e78d59c0411ddbeede8d2324f0.tar.gz |
Make product consistently yield an array of N elements instead of N arguments
Inconsistency pointed out by @mame:
```
>> Enumerator.product([1], [2], [3]).to_a
=> [[1, 2, 3]]
>> Enumerator.product([1], [2]).to_a
=> [[1, 2]]
>> Enumerator.product([1]).to_a
=> [1]
>> Enumerator.product().to_a
=> [nil]
```
Got fixed as follows:
```
>> Enumerator.product([1], [2], [3]).to_a
=> [[1, 2, 3]]
>> Enumerator.product([1], [2]).to_a
=> [[1, 2]]
>> Enumerator.product([1]).to_a
=> [[1]]
>> Enumerator.product().to_a
=> [[]]
```
This was due to the nature of the N-argument funcall in Ruby.
Diffstat (limited to 'tool')
0 files changed, 0 insertions, 0 deletions