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

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -