Skip to content

Instantly share code, notes, and snippets.

@diegoeche
Created December 21, 2013 19:14
Show Gist options
  • Save diegoeche/8073588 to your computer and use it in GitHub Desktop.
Save diegoeche/8073588 to your computer and use it in GitHub Desktop.
2.0.0p247 :012 > [nil,2,3].lazy.map { |x|
puts "evaluating #{x}. This could be expensive"
x ? x * 10 : x
}.detect { |x|
x && x >= 20
}
evaluating . This could be expensive
evaluating 2. This could be expensive
=> 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment