Skip to content

Instantly share code, notes, and snippets.

@nixpulvis
Created December 17, 2012 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nixpulvis/4316018 to your computer and use it in GitHub Desktop.
Save nixpulvis/4316018 to your computer and use it in GitHub Desktop.
get_if for arrays.
class Array
# Return the first element where the given block returns true for.
def get_if
each { |v| return v if yield v }
return false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment