Created
February 5, 2015 22:20
-
-
Save mayfer/ffb839fd5bd24aa72ede to your computer and use it in GitHub Desktop.
Block example (re-writing select with puts)
This file contains hidden or 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 select(arr) | |
arr.each do |elem| | |
if yield elem | |
puts elem | |
end | |
end | |
end | |
select([1, 5, 7, 2, 4, 6]) do |elem| | |
elem % 2 == 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment