zip()
Given an array [1,2,3] and [“A”,”B”,”C”], I wanted the result [[1,”A”],[2,”B”],[3,”C”]]
>> a,b = [1,2,3], ["A","B","C"]
=> [[1, 2, 3], ["A", "B", "C"]]
>> a
=> [1, 2, 3]
>> b
=> ["A", "B", "C"]
>> a.zip(b)
=> [[1, "A"], [2, "B"], [3, "C"]]
Transpose also achieves the same thing.
>> [a,b].transpose
=> [[1, "A"], [2, "B"], [3, "C"]]
2 years ago