Polyov
Polyov

Reputation: 2321

Does Lua have OR comparisons?

I'm just starting out using Lua, and I was wondering (because I can't find it on the website) if Lua has a OR operator, like how in other languages there is ||:

if (condition == true || othercondition == false) {
 somecode.somefunction();
}

whereas in Lua, there is

if condition then
    x = 0
end

how would i write an IF block in Lua to use OR?

Upvotes: 28

Views: 85365

Answers (1)

Puppy
Puppy

Reputation: 147036

With "or".

if condition or not othercondition then
    x = 0
end

As the Lua manual clearly states.

Upvotes: 40

Related Questions