Hi all.

What I'm trying to do, is a program that has a hash with predefined
words and its corresponding meaning, then when I enter a word that is
found in the hash, I must return its meaning, and if not found in the
hash, should return the most similar word.

This is the code that was doing:

#######################################################################

words={
"computer" => "an electronic device ...",
"cat" => "a small domesticated carnivorous ...",
"home" => "the place where one lives permanently ...",
"dog" => "a domesticated carnivorous mammal ... "
}

like=""
print "Enter word to search: "
w=gets.chomp.to_s

word.each{|k,v|
if k==w
    puts v
else
    for i in 0..10
  if k[i]==w[i]
             like[i]=w[i]
  end
     end
end
}
################################################################

for example if I enter the word home, returns me its meaning:

home => "the place where one lives permanently ..."

and if such entry hom, meaning me back home with any word and thus
similar to those found in the hash.

Thanks.

-- 
Posted via http://www.ruby-forum.com/.