View Single Post
08-02-13, 07:06 PM   #18
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by semlar View Post
You can't do "if var == 1 or 2 or 3", it's not the same as "if var == 1 or var == 2 or var == 3", it will always return true because "if 2" will always evaluate to true.
To clarify even further:

Code:
if var == 1 or 2 or 3 then
   -- do X
end
Is functionally identical to:

Code:
if var == 1 then
   -- do x
elseif 2 then
   -- do x
elseif 3 then
   -- do x
end
It is NOT the same as:

Code:
if var == 1 then
   -- do x
elseif var == 2 then
   -- do x
elseif var == 3 then
   -- do x
end
If you want to do that third thing in one go, you need to write it this way:

Code:
if var == 1 or var == 2 or var == 3 then
   -- do x
end
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote