Reputation: 7622
I have two arrays,
a = [1, 2]
b = [:a]
I want to get the result as
[[1, :a], [2, :a]]
Is there any methods for this?
Upvotes: 3
Views: 1170
Reputation: 83680
Also you can do it this way
[a,b*a.size].transpose
#=> [[1, :a], [2, :a]]
Upvotes: 0
Reputation: 31077
Use the Array#product:
a = [1, 2]
b = [:a]
a.product(b)
=> [[1, :a], [2, :a]]
Upvotes: 6