Created
September 12, 2011 02:36
-
-
Save jcalvert/1210479 to your computer and use it in GitHub Desktop.
to_hash
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 to_hash | |
Hash[self.zip(map{|i| yield i})] if block_given? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why do people sometimes have this? Splat seems superflous here.
? Hash[*self.zip(map{|i| yield i}).flatten] if block_given?