Return the Cartesian product of the two sets : product « Array « Ruby






Return the Cartesian product of the two sets

a = [1,2,3]
a.product(['a','b'])       # => [[1,"a"],[1,"b"],[2,"a"],[2,"b"],[3,"a"],[3,"b"]]
[1,2].product([3,4],[5,6]) # => [[1,3,5],[1,3,6],[1,4,5],[1,4,6], etc... ]

 

Related examples in the same category