Project

General

Profile

« Previous | Next » 

Revision 308ccbae

Added by Akinori MUSHA almost 3 years ago

Make product consistently yield an array of N elements instead of N arguments

Inconsistency pointed out by @mame (Yusuke Endoh):

>> 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.