+ 2
Can someone please help me with this code, I can't seem to find out where the problem is or what needs to be done to make it run
system "clear" def eg_1() system "clear" print ("What is your name?") name = gets system "clear" if name == "luke" || "Luke" puts "Hello there Master, how are you today?" elsif puts "You are not my master, Go away!" end def eg_2() system "clear" print "What is you age?" age = gets system "clear" if age >= 18 puts "You may enter Sir" elsif age < 18 puts "You may not enter, you are not old enough." end print "Ask a question: " question = gets if question == "name" || "Name" puts eg_1 elsif question == "age" || "Age" puts eg_2 end
5 Answers
+ 4
It's because you don't do comparison like that. To check if the name is luke or Luke, you have to do:
name == "luke" || name == "Luke"
+ 2
Maybe the problem is, that you didn't make the age a number, and tried to compare it to a number
0
Thanks Airree, I changed that and I still get the same error
test.rb:41: warning: string literal in condition
test.rb:41: warning: string literal in condition
test.rb:41: syntax error, unexpected end-of-input, expecting keyword_end
The file name is test...
0
gotten rid of the first 2 warnings, but the last one persists
0
Sorry, I solved it. I hadn't ended the if loops....