Created
June 13, 2016 14:10
-
-
Save marcusshepp/ddf7e5653d767963b050956caff80b2a to your computer and use it in GitHub Desktop.
detect
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
# 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