Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created November 26, 2015 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/6b132da1b8df9c8591d7 to your computer and use it in GitHub Desktop.
Save anonymous/6b132da1b8df9c8591d7 to your computer and use it in GitHub Desktop.
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