Created
February 11, 2013 23:17
-
-
Save pjlowry/4758536 to your computer and use it in GitHub Desktop.
create your own dictionary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dictionary | |
attr_accessor :new_hash | |
def initialize | |
@hash = Hash.new | |
end | |
def new_entry(word, definition) | |
@word = word | |
@definition = definition | |
@hash.merge!({@word => @definition}) | |
end | |
def list_dictionary | |
puts @hash.map {|word, definition| word } | |
end | |
def search(letters) | |
@hash.select {|word, definition| word.include?(letters)} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment