Last active
December 14, 2015 13:58
-
-
Save JackDanger/5097046 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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