friyllie
(friyllie)
#1
Essentially, I am trying to find out which one of the 2 methods below is correct. (Or if both are.)
I’ve looked on the creator hub and some other posts on here, but I couldn’t find a definitive answer. I’ts probably painfully obvious.
if statement 1 (Repeating the “Key == X”)
if Key == "1" or Key == "2" or Key == "3" then
print("Hello")
end
if statement 2 (Just using or, without stating the “Key == X” for every value )
if Key == "1" or "2" or "3" then
print("Hello")
end
Thanks in advance for any answer.
1 Like
Yes you would have to be very explicit with what you want to compare, so the first example is the correct one.
The first one translated to English would sound like this:
- is key equal to “1”?
- or is key equal to “2”?
- or is key equal to “3”?
The second one sounds like this:
- is key equal to “1”
- or is “2” a truthy value?
- or is “3” a truthy value?
2 Likes
system
(system)
Closed
#3
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.