Hey ,Guys ,I have a question. I want to transform the array.[[1, [-1, 1]], [1, [20, 8]], [1, [30, 4]], [1, [40, 2]], [1, [41, 6]], [1, [70, 243]]] into this style [1,[[-1,1],[20,8],[30,4]...] or a hash [1=>…]
How can i do this trick? thank you !
Hey ,Guys ,I have a question. I want to transform the array. [[1, [-1,
Share
Dict method:
For clarity Chuck’s suggestion would bring this to:
You can then get an array from this in the style you want by doing:
Which will give you:
Notice the extra array, because if you had arrays begining with 2 you’d have another set at the end. So
new_arr[0]will give you the array you were originally looking for.