Created
February 29, 2012 19:57
-
-
Save acook/1943982 to your computer and use it in GitHub Desktop.
Array deletify - removes element matching block and returns it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def deletify! &block | |
self.each do |element| | |
return self.delete(element) if yield(element) | |
end | |
nil | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment