- Lua Quick Start Guide
- Gabor Szauer
- 366字
- 2021-08-05 10:30:41
Relational operators
Relational operators compare two things (usually numbers) and always evaluate to a Boolean result. These operators are used to answer questions such as is 10 less than 20? Relational operators test for equality, inequality, and which of two arguments is less than or greater than the other.
The equality operator (==) checks whether the values of the two operands are equal or not. If they are equal, the operator evaluates to true, otherwise it evaluates to false. Here are examples:
x = 2 == 2 -- true
y = 2 == 3 -- false
z = "nine" == 9 -- false
The inequality operator (~=) checks whether the values of the two operands are equal or not. If they are NOT equal, the operator evaluates to true, otherwise it evaluates to false. Here is an example:
x = 2 ~= 2 -- false
y = 2 ~= 3 -- true
z = "nine" ~= 9 -- true
The greater than operator (>) checks whether the first operand is greater than the second operand. If it is, the operator evaluates to true, otherwise to false. Here is an example:
x = 4 > 5 -- false
y = 4 > 4 -- false
z = 4 > 3 -- true
The greater than or equal to operator (>=) checks whether the first operand is greater than or equal to the second operand. If it is, the operator evaluates to true, otherwise to false. Here is an example:
x = 4 >= 5 -- false
y = 4 >= 4 -- true
z = 4 >= 3 -- true
The less than operator (<) checks whether the first operand is less than the second operand. If it is, the operation evaluates to true, otherwise to false. Here is an example:
x = 3 < 2 -- false
y = 3 < 3 -- false
z = 3 < 4 -- true
The less than or equal to operator (<=) checks whether the first operand is less than or equal to the second operand. If it is, the operation evaluates to true, otherwise to false. Here is an example:
x = 3 <= 2 -- false
y = 3 <= 3 -- true
z = 3 <= 4 -- true
- ASP.NET Core:Cloud-ready,Enterprise Web Application Development
- Cocos2d-x游戲開發:手把手教你Lua語言的編程方法
- R的極客理想:工具篇
- 差分進化算法及其高維多目標優化應用
- Nginx Essentials
- C++ 從入門到項目實踐(超值版)
- Scala程序員面試算法寶典
- Oracle 18c 必須掌握的新特性:管理與實戰
- Python程序設計與算法基礎教程(第2版)(微課版)
- Raspberry Pi Robotic Blueprints
- Orchestrating Docker
- 軟件工程與UML案例解析(第三版)
- Photoshop智能手機APP界面設計
- Mastering Embedded Linux Programming
- INSTANT Premium Drupal Themes