Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Lua have OR comparisons?

Tags:

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?

like image 514
Polyov Avatar asked Jun 30 '12 04:06

Polyov


People also ask

Can you do ++ in Lua?

++ is not a C function, it is an operator. So Lua being able to use C functions is not applicable.

Does Lua use C#?

Unfortunately, this will not work, as standard Lua is written in C, which, while very similar to C# in it's structure, is not C# and is not compatible with the . NET framework.

HOW DO YOU DO NOT equal to in Lua?

(A == B) is not true. Checks if the value of two operands are equal or not, if values are not equal then condition becomes true. (A ~= B) is true. Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true.

Does ~= mean not equal?

The ~= symbol or operator in Lua is known as the not-equal to operator. In many programming languages you might have seen the symbol != which is also known as the not equals operator.


1 Answers

With "or".

if condition or not othercondition then     x = 0 end 

As the Lua manual clearly states.

like image 121
Puppy Avatar answered Oct 24 '22 00:10

Puppy