Skip to content

Instantly share code, notes, and snippets.

@marcusshepp
Created June 13, 2016 14:10
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 marcusshepp/ddf7e5653d767963b050956caff80b2a to your computer and use it in GitHub Desktop.
Save marcusshepp/ddf7e5653d767963b050956caff80b2a to your computer and use it in GitHub Desktop.
detect
# returns the first element that returns `true` after being passed to `block`
x = [1, 2, 3]
x = x.detect{|i| i > 1}
# => 2
x == 2
# => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment