marcusshepp
6/13/2016 - 2:10 PM

detect

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