From: "Damián M. González" Date: 2012-10-10T22:46:42+09:00 Subject: Re: Simulation of a dictionary Hi Joao, firs of all, it's not necessary put .to_s() in w, since gets() means "get string", so everything inputted for the user will be a string. Second, I recommend you .downcase() the w variable, because the user may input "CAT", if you will have personal nouns in the dictionary you'll have to do something like the next showed. I also though a way to find which is the closest word to what is tipped. Take a look, I tested it a bit and worked. #encoding: utf-8 words={ "computer" => "an electronic device ...", "cat" => "a small domesticated carnivorous ...", "home" => "the place where one lives permanently ...", "dog" => "a domesticated carnivorous mammal ... " } loop do print "Enter word to search: " w=gets.strip #you can tipe 'exit' to go out if w == 'exit' then exit end resultado = \ if words.has_key?(w) then words[w] elsif words.has_key?(w.downcase) then words[w] elsif words.has_key?(w.downcase.capitalize) then words[w] else nil end unless resultado words[w] = "erase after.." place = nil words_in_array = words.sort words_in_array.each_with_index do |value, index| if value[0] == w then place = index end break if place != nil end possible_words = [words_in_array[place.-(1)][0], \ words_in_array[place.+(1)][0]] resultado = \ "The word doesn't match, meaby did you mean: #{possible_words.join(' or ')}. Try again" words.delete(w) end puts resultado end -- Posted via http://www.ruby-forum.com/.