if a == b then
--
else
if a == c then
--
else
if a == d then
--
else
--
end
end
end
This is just confusing to look at… It unnecessarily nests conditions which should be considered in the same scope. I’m sure there are use cases for this, but generally speaking there are cleaner alternatives.
Because else refers to literally anything else than the other if statement
local myString = 2
if myString == "2" then
-- code will not be executed
else
-- literally anything else that is not myString = "2", since myString equals to only 2, the number, this part will be executed
end
elseif makes sure that another condition is met but doesn’t execute neither if the statement is false
local myString = 2
if myString == "2" then
-- code will not be executed
elseif myString == 2 then
-- makes sure another condition is met, if false, it skips. This code will be executed
else
-- this code will not be executed since the elseif statement is true
end
I’ve provided evidence why else is eh and using an elseif is in general better if you want more accuracy. So you would prefer something like this?
if false then
else
if false then
else
if false then
else
if false then
else
if false then
else
if false then
else
if false then
else
if false then
else
if false then
else
if false then
else
if false then
else
if false then
else
if false then
else
if false then
else
if false then
else
if false then
else
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end