Skip to content

Instantly share code, notes, and snippets.

@bakkdoor
Created November 25, 2010 17:56
Show Gist options
  • Save bakkdoor/715717 to your computer and use it in GitHub Desktop.
Save bakkdoor/715717 to your computer and use it in GitHub Desktop.
def map: block {
"Returns a new @Array@ with the results of calling a given block for every element"
coll = []
each: |x| {
if: (block argcount == 0) then: {
coll << (block call_with_receiver: x) # <- had to add this part..
} else: {
coll << (block call: [x])
}
}
coll
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment