Skip to content

Instantly share code, notes, and snippets.

@RavensKrag
Last active December 28, 2015 08:59
Show Gist options
  • Save RavensKrag/7476055 to your computer and use it in GitHub Desktop.
Save RavensKrag/7476055 to your computer and use it in GitHub Desktop.
Ruby Enumeration interface, in reverse order
numbers = (1..10).to_a # array of numbers 1-10 inclusive on both ends
numbers.detect {|i| i % 2 == 0} # first value divis by 2, starting from the front
numbers.reverse_each.detect {|i| i % 2 == 0 } # start from the rear instead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment