Reputation: 353
Well I am learning Lua at the moment and I wanted to write a little script. It's just for practice and understanding how Lua is working.
local name = io.read()
if name == Test
then print("Right")
else print("Wrong")
end
Normally the output should be "Right" if I enter "Test" but it always prints "Wrong". I tried it many times and wrote the code in other forms but didn't get my solution.
Can anyone help me please?
Upvotes: 3
Views: 12426
Reputation: 263617
You're missing a set of quotation marks.
This:
if name == Test
compares the values of two variables, name
and Test
.
You want this:
if name == "Test"
Lua doesn't require variables to be declared, so this is an easy mistake to make.
Upvotes: 12