Ruby: Removing arrays from a 2d array that match a certain string -
I have a 2d array that looks like
array = [["apple"] 10], ["banana", 20], ["plum", 30], ["oranges", 10]] and another array that looks
badstuff_array = ["bananas", "plums"] and I want to remove from arrays in which badstuff_array . So any output can help with goodstuff_array = [["apple", 10], ["oranges", 10]] in ?
This combination can be done very easily with:
Array.delete_if {| X | badstuff_array.include? X [0]} # = & gt; [["Apple", 10], ["oranges", 10]]
Comments
Post a Comment