Lua Operators-Lua Logical Operators - Lua (programming language)

What are the logical operators in Lua?

Below table shows all the logical operators supported by Lua language. Assume variable A holds true and variable B holds false then

Operator

Description

Example

and

Called Logical AND operator. If both the operands are non-zero, then condition becomes true.

(A and B) is false.

or

Called Logical OR Operator. If any of the two operands is non-zero then condition becomes true.

(A or B) is true.

not

Called Logical NOT Operator. Used to reverse the logical state of its operand. If a condition is true, then Logical NOT operator will make false.

!(A and B) is true.

Example

Try below example to understand all the logical operators available in the Lua programming language

When you build and execute the above program, it produces the following result

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Lua (programming language) Topics