Vote count:
0
How would I combine the subarrays within this array [["0", "0", "0"], ["0", "0", "0"], ["1"]]? I want to add a comma in between each subarray so that it would read 000,000,1.
I have tried using *"," but it will combine the whole array together and give me 0,0,0,0,0,0,1 instead. Thanks for your help!
asked 3 mins ago
1 Answer
Vote count:
0
You mean like this?
array = [["0", "0", "0"], ["0", "0", "0"], ["1"]]
array.map(&:join).join(',')
# => "000,000,1"
answered 39 secs ago
How to combine subarrays within an array in Ruby?
Aucun commentaire:
Enregistrer un commentaire