-
-
Save anonymous/6b132da1b8df9c8591d7 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
class Array | |
def my_each | |
c = 0 | |
until c == size | |
yield(self[c]) | |
c += 1 | |
end | |
self | |
end | |
def my_map | |
p self.inspect | |
acc = [] | |
my_each { |a| acc << yield(a) } | |
p acc | |
end | |
end | |
names = [ "david", "black", "foo" ] | |
names.my_map { |name| name.upcase } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment