Expressions and Operators
Expressions and Operators
The basic expressions in Lua consist of: expressions in parentheses,nil , numbers, literals, variables, upvalues, functions, function calls, and table constructors.The values returned by an expressionmust be adjusted to a single value.For relational and logical operators, nil is false, non-nil is true.
~= |
<= |
>= |
< |
> |
== |
= |
+ |
- |
* |
/ |
% |
( ) |
{ } |
[ ] |
; |
, |
. |
.. |
... |
The Lua operator list and precedence, from the lower to the higher priority (use parentheses to override precedence):
left |
and or |
Logical AND, logical OR |
left |
< > <= >= ~= == |
Relational operators |
left |
.. |
Concatenation |
left |
+ - |
Arithmetic addition, subtraction |
left |
* / |
Arithmetic multiplication, division |
right |
not - (unary) |
Logical NOT, unary minus |
right |
^ |
Exponentiation |
Pre-compiler optimizationsmay change some results if you define non-associative tag methods for these operators.Optimizations do not change normal results. An exponentiation always calls a tag method; this can be redefined.
Suggerimento |
|
Per scrivere, con una tastiera italiana, alcuni di questi caratteri, รจ necessaria una "composizione" di tasti:
|