Last active
March 13, 2017 20:31
-
-
Save joecorcoran/1dd69d67edf10991c87ed90febe7d63a 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
# Define the method #each (without using Enumerable#each) so that | |
# the following prints three lines: | |
# def each ... | |
# ... | |
# end | |
rgb = ['red', 'blue', 'green'] | |
each(rgb) do |c| | |
puts "I like #{c}!" | |
end | |
# Solution below, no peeking :) | |
def each(arr, &block) | |
for x in arr do | |
block.call(x) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment