tutorial on the use of relational operators in Lua

Source: Internet
Author: User
Tags lua

This article mainly introduces the use of relational operators in Lua, which is the basic knowledge of LUA learning, and needs friends to refer to the following

The following table lists the relational operators that are supported by all LUA languages. Suppose variable a holds 10 and variable B holds 20:

Example

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

The code is as follows:

A = 21

b = 10

if (a = = b)

Then

Print ("line 1-a are equal to B")

Else

Print ("line 1-a isn't equal to B")

End

if (a ~= b)

Then

Print ("line 2-a isn't equal to B")

Else

Print ("line 2-a are equal to B")

End

if (a < b)

Then

Print ("line 3-a is less than B")

Else

Print ("line 3-a are not less than B")

End

if (a > B)

Then

Print ("line 4-a is greater than B")

Else

Print ("line 5-a are not greater than B")

End

--Lets change value of a and B

A = 5

b = 20

if (a <= b)

Then

Print ("line 5-a are either less than or equal to B")

End

if (b >= a)

Then

Print ("line 6-b are either greater than or equal to B")

End

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

The code is as follows:

Line 1-a isn't equal to B

Line 2-a isn't equal to B

Line 3-a are not less than B

Line 4-a is greater than B

Line 5-a are either less than or equal to B

Line 6-b are either greater than or equal to B

Related Article

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.