Skip to content

Instantly share code, notes, and snippets.

@JackDanger
Last active December 14, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JackDanger/5097046 to your computer and use it in GitHub Desktop.
Save JackDanger/5097046 to your computer and use it in GitHub Desktop.
def odd(list)
list.each_with_index do |item, index|
yield item if index % 2 == 0
end
end
def even(list)
list.each_with_index do |item, index|
yield item if index % 2 == 1
end
end
def more_than_3(list)
list.select {|item| item > 3 }
end
even([1,2,3,4,5]) {|item| puts item }
odd([1,2,3,4,5]) {|item| puts item }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment