Skip to content

Instantly share code, notes, and snippets.

@merbjedi
Created December 5, 2008 08:03
Show Gist options
  • Save merbjedi/32279 to your computer and use it in GitHub Desktop.
Save merbjedi/32279 to your computer and use it in GitHub Desktop.
class Hash
# returns a new hash with key,value pairs for the specified keys
def choose(*keys)
result = {}
keys.each do |key|
result[key] = self[key]
end
return result
end
end
class NilClass
def choose(*keys)
return {}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment