Skip to content

Instantly share code, notes, and snippets.

@trans
Created August 23, 2011 18:00
Show Gist options
  • Save trans/1166007 to your computer and use it in GitHub Desktop.
Save trans/1166007 to your computer and use it in GitHub Desktop.
Able to use block with zip
class Array
def zip(a, &b)
if b
r = []
bs = lambda{ |x| r << b.call(*x) }
super(a, &bs)
return r
else
super(a)
end
end
end
# example
[1,2,3].zip([5,6,7], &:+) #=> [6,8,10]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment