Skip to content

Instantly share code, notes, and snippets.

@peterlazar1993
Last active August 29, 2015 14:23
Show Gist options
  • Save peterlazar1993/936a957765a64e54b2ff to your computer and use it in GitHub Desktop.
Save peterlazar1993/936a957765a64e54b2ff to your computer and use it in GitHub Desktop.
HW
class Array
def custom
index = 0
a = []
while (self[index] != nil)
a[index] = yield self[index]
index += 1
end
a
end
end
p [1, 2, 3].custom {|x| x + 1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment