Skip to content

Instantly share code, notes, and snippets.

@pjlowry
Created February 11, 2013 23:17
Show Gist options
  • Save pjlowry/4758536 to your computer and use it in GitHub Desktop.
Save pjlowry/4758536 to your computer and use it in GitHub Desktop.
create your own dictionary
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