I have a simple each statement on an array
game.each{|match| winner += rps_game_winner(match)
winner is previously defined as winner = []
rps_game_winner will return an array of 2 elements.
I want the winner to be and array of an array of 2 elements.
instead if game has 2 matches i will get an array for 4 elements.
Is there a way to quickly convert an array of 4 elements to an array with 2 arrays of 2 elements.
Or to make winners an array of 2 elements in the first place
for example winners should equal [[“rob”,”Hi”],[“sally”,”no”]] instead of [“rob”,”Hi”,”sally”,”no”]
Don’t use
+=; use<<:While
+combines two arrays into one,<<adds new elements. If a new element happens to itself be another array, it’s still added as an element, not merged in.If you prefer words to punctuation, you can also spell it
push: