81
In addition, the type of operation (string, integer, etc) and the final value of the expression are determined
by the first token. If a string cannot be resolved to an integer during an integer operation, it takes on the
value of
0
(zero).
Some examples:
This expression...
... resolves to this
value.
Notes
3+4*5
35
No order of operations.
3+(4*5)
23
Priority is indicated by
parentheses.
“Hello”*3
“HelloHelloHello” *
is a string operator here.
“Hello”+3
“Hello3”
The number
3
becomes
part of the
“Hello”
string
because the string comes
first.
Hello+3
7
Assuming
Hello
is a
number Variable holding a
value of
4
.
3+”6”
9
The string
“6”
is valued
as
6
, a number, and
3
is a
number.
3+”Hello”
3
The string is treated as
0
because
“Hello”
has no
integer interpretation.
Operators
Operators
Operators
Operators
The operators that are supported are:
•
Arithmetic operations: +, -, *, /
•
Logical comparison operators: ==, != , <, <=, >, >=
•
Logical operators: &&, ||, !
•
Bitwise operators: &, | , ~
•
Range operator: in
•
Assignments: =, +=, -=, *=, /=, &=, |=