jeudi 10 novembre 2022

2 arrays insert via (column) double dimension array ruby (short method)

From this initialize array:

x = []
y = [1,2,3,4,5]
z = ["a", "b", "c", "d", "e"]

I want x result to be like this:

=> [[1,"a"], [2,"b"], [3,"c"], [4,"d"], [5,"e"]]

Is there any short method to do this without using nested loop?

Aucun commentaire:

Enregistrer un commentaire