I can do:
@items = @items.select {|i| i.color == 'blue'} @items = @items.select {|i| i.color == 'blue' || i.color == 'red'}
What if they give me an unknown number of colors and I want to select all of them? i.e.
['red','blue','green','purple']
I worked on a mess of code that creates several temporary arrays and then merges or aligns them into one, but I'm really not happy with it.
arrays ruby
Ryan florence
source share