Created
November 25, 2013 11:03
-
-
Save luctraonmilin/7639717 to your computer and use it in GitHub Desktop.
A Ruby programming interview question I had a few days ago: implement the method each for Array. Here is my answer.
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
class Array | |
def each(&block) | |
map &block | |
self | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment