- Lua Quick Start Guide
- Gabor Szauer
- 281字
- 2021-08-05 10:30:40
Operators
Operators such as addition +, string concatenation .., and even the assignment operator = have been used throughout this book. Let's take some time to cover in detail what operators are and how they work. Operators fall into one of the following categories:
- Arithmetic operators do math.
- Relational operators always return a Boolean value: true or false. Relational operators are used to compare the relationship between two things, for example, by checking whether one number is smaller than another number.
- Logical operators express complex relations such as and/or. For example, logical operations can be used to check whether a number is less than seven AND greater than two.
- Misc operators: All other operators, such as assignment, fall into this category.
Operators can be unary or binary. A unary operation works on only one operand. For example, the minus sign (-) is the unary negation operator. It returns the negative value of a number:
x = -7 -- negation operator applied to the constant 7
y = -x -- negation operator applied to the x variable
-- x: -7, y: 7
A binary operator on the other hand operates on two operands. The binary subtraction operator also uses the minus sign (-), but it is a completely different operator from its unary counterpart. An example of the binary subtraction operator would be:
x = 7 - 3 -- Operand 1 is the constant 7, Operand 2 is the constant 3
y = x - 1 -- Operand 1 is the variable x, Operand 2 is the constant 1
z = x - y -- Operand 1 is the variable x, Operand 2 is the variable y
Most operators will be binary, that is, they will work on two operands.
- JavaScript 從入門到項目實踐(超值版)
- R語言數據可視化之美:專業圖表繪制指南
- HTML5 Mobile Development Cookbook
- C語言從入門到精通(第4版)
- PostgreSQL 11從入門到精通(視頻教學版)
- YARN Essentials
- 精通Python自然語言處理
- Visual Basic程序設計上機實驗教程
- Python機器學習算法: 原理、實現與案例
- PHP+MySQL動態網站開發從入門到精通(視頻教學版)
- Scratch從入門到精通
- Python大規模機器學習
- Visual Basic語言程序設計基礎(第3版)
- Learning Unreal Engine Game Development
- MySQL數據庫應用實戰教程(慕課版)