Guest User

Untitled

a guest
Dec 14th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. class Dictionary
  2.  
  3.  
  4. def entries
  5. @english = {}
  6. end
  7.  
  8. # Then, you should be
  9. # able to add words and their definition
  10. #by calling a method and passing in a hash as an argument
  11.  
  12. def add(new_hash)
  13. @english.merge(new_hash)
  14. end
  15. end
  16.  
  17. #You should also be able to list all of the words and
  18. #their definitions in another method
  19.  
  20. def entries
  21. @english
  22. end
  23.  
  24.  
  25. #Finally, you should be able to search the dictionary
  26. #by passing in the first few letters of a word
  27.  
  28. def search
  29. end
  30.  
  31. end
  32.  
  33. my_dict = Dictionary.new
  34. my_dict.add('first' => 'thing1')
  35. my_dict.add('second' => 'thing2')
Add Comment
Please, Sign In to add comment