Skip to content

Instantly share code, notes, and snippets.

@jCrip
Created September 5, 2013 03:06
Show Gist options
  • Save jCrip/6445583 to your computer and use it in GitHub Desktop.
Save jCrip/6445583 to your computer and use it in GitHub Desktop.
Get Odd or Even entries of an array
class Array
def odd_values
self.values_at(* self.each_index.select {|i| i.odd?})
end
def even_values
self.values_at(* self.each_index.select {|i| i.even?})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment