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 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

1st Jul 2019, 7:44 AM
Luke PJ
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"
1st Jul 2019, 7:59 AM
Airree
Airree - avatar
+ 2
Maybe the problem is, that you didn't make the age a number, and tried to compare it to a number
1st Jul 2019, 3:18 PM
Airree
Airree - avatar
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...
1st Jul 2019, 3:13 PM
Luke PJ
0
gotten rid of the first 2 warnings, but the last one persists
1st Jul 2019, 3:55 PM
Luke PJ
0
Sorry, I solved it. I hadn't ended the if loops....
1st Jul 2019, 3:59 PM
Luke PJ