Guest User

Untitled

a guest
Feb 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. class Hash
  2. # returns a new hash with key,value pairs for the specified keys
  3. def choose(*keys)
  4. result = {}
  5. keys.each do |key|
  6. result[key] = self[key]
  7. end
  8. return result
  9. end
  10. end
  11.  
  12. class NilClass
  13. def choose(*keys)
  14. return {}
  15. end
  16. end
Add Comment
Please, Sign In to add comment