1.3- why doesn't this statement work?


#1

print "Choose happy or sad."
vh = gets.chomp
if vh = happy
print "Congrats with the choice!"
else
print "It's a three letter word."
end
This code should respond based on the word choice. What is actually happening is after I put in the input I get an error message. The message states "undefined local variable or method" What am I missing and why is this happening?


#2

For a comparison we use, ==.


#3

mtf, I tried vh == happy and it's the same error message


#4

Strings must be written in quotes, either single of double.


#5

Thanks. I always forget that detail.


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.