How to Use Relational operators in Lua

Source: Internet
Author: User

How to Use Relational operators in Lua

This article describes how to use Relational operators in Lua. It is the basic knowledge in Lua learning. For more information, see

The following table lists all Relational operators supported by Lua. Assume that variable A holds 10 and variable B holds 20:

Example

Try the following example to understand the Relational operators provided by all Lua programming languages:

The Code is as follows:

A = 21

B = 10

If (a = B)

Then

Print ("Line 1-a is equal to B ")

Else

Print ("Line 1-a is not equal to B ")

End

If (~ = B)

Then

Print ("Line 2-a is not equal to B ")

Else

Print ("Line 2-a is equal to B ")

End

If (a <B)

Then

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

Else

Print ("Line 3-a is not less than B ")

End

If (a> B)

Then

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

Else

Print ("Line 5-a is not greater than B ")

End

-- Lets change value of a and B

A = 5

B = 20

If (a <= B)

Then

Print ("Line 5-a is either less than or equal to B ")

End

If (B> =)

Then

Print ("Line 6-B is either greater than or equal to B ")

End

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

The Code is as follows:

Line 1-a is not equal to B

Line 2-a is not equal to B

Line 3-a is not less than B

Line 4-a is greater than B

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

Line 6-B is either greater than or equal to B

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.