ruby on rails - Reject element from array in efficient way -


my array is

  arr = ["wow what", "what anis", "I am in", "I am in", "in the night", "at night", "at night", "at night", "at night", "at night", "day", "day", " "In Delhi", "in Delhi" but "I am", "going", "go", "us"] arr.each do. El | | If! El.match ('in') & amp; Amp; ! El.match ('is'). Empty? Fresh_arb & lt; & Lt;   

But I have 110k elements array and it is giving 8sec that, this is too much time I can do it in any other way

Thx < / P>

Use delete_if

  arr .delete_if do | E E. Match ('in') & amp; Amp; E.match ('is'). Empty? End arr    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -