RubyFlow : The Ruby Community Blog

Home   Submit   Sign Up   Log In   leaders   Twitter   RSS Feed  
 

Array#extract_if

A handy Array method that essentially finds and removes an item from an array in one go - returning that item. Surprisingly no core methods (delete drop etc) does this, nor does activesupport provide it.

Comments

"A handy Array method that essentially finds and removes an item from an array in one go"

Ruby on its own already has this (Array#reject!) :

@links.reject!{|link| link.match /wikipedia.com/ }harisamin - July 26, 2013 19:26

Post a Comment

Comment abilities for non registered users are currently deactivated, pending time to add a proper CAPTCHA to solve the escalating spam problem. Sorry!