Reputation: 75
What's the difference between elseif
and else if
in Lua? I don't know if they're the same but shorter.
x= 100
y= 100
if x > 90 then
...
else if y > 110 then
...
else
...
end
end
if x > 90 then
...
elseif y > 110 then
...
else
...
end
Upvotes: 2
Views: 2178
Reputation: 28954
There is no else if
in Lua.
The proper syntax is elseif
.
Let's fix your intedation:
if x > 90 then
...
else
if y > 110 then
...
else
...
end
end
It's just a bit more complicated. This only makes sense if you need more else blocks as well. If there is only one else block for all conditions then elseif is sufficient.
Upvotes: 2