Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment