Skip to content

Instantly share code, notes, and snippets.

@jcalvert
Created September 12, 2011 02:36
Show Gist options
  • Save jcalvert/1210479 to your computer and use it in GitHub Desktop.
Save jcalvert/1210479 to your computer and use it in GitHub Desktop.
to_hash
class Array
def to_hash
Hash[self.zip(map{|i| yield i})] if block_given?
end
end
@jcalvert
Copy link
Author

Why do people sometimes have this? Splat seems superflous here.
? Hash[*self.zip(map{|i| yield i}).flatten] if block_given?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment