How do you add an array to another array in Ruby and not end up with a multi-dimensional result?
You’ve got a workable idea, but the #flatten! is in the wrong place — it flattens its receiver, so you could use it to turn [1, 2, [‘foo’, ‘bar’]] into [1,2,’foo’,’bar’]. I’m doubtless forgetting some approaches, but you can concatenate: a1.concat a2 a1 + a2 # creates a new array, as does a1 += a2 … Read more