The logical operators in LUA use the detailed

Source: Internet
Author: User
Tags logical operators lua

This article focuses on the use of logical operators in Lua, and is the basic knowledge of LUA's introductory learning, and the friends you need can refer to

The following table lists the logical operators that are supported by all LUA languages. Suppose variable a holds true, and variable B holds false:

Example

Try the following example to understand the logical operators provided by all of the LUA programming languages:

The code is as follows:

A = 5

b = 20

if (A and B)

Then

Print ("line 1-condition is true")

End

if (A or B)

Then

Print ("line 2-condition is true")

End

--lets change the value OFA and b

A = 0

b = 10

if (A and B)

Then

Print ("line 3-condition is true")

Else

Print ("line 3-condition are not true")

End

if (not (A and B))

Then

Print ("line 4-condition is true")

Else

Print ("line 3-condition are not true")

End

When the above program is established and executed, it produces the following results:

The code is as follows:

Line 1-condition is True

Line 2-condition is True

Line 3-condition is True

Line 3-condition are not true

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.