This expression...
... resolves to this
value.
Notes
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
The operators that are supported are:
•
Arithmetic operations: +, -, *, /
•
Logical comparison operators: ==, != , <, <=, >, >=
•
Logical operators: &&, ||, !
•
Bitwise operators: &, | , ~,^
•
Range operator: in
•
Assignments: =, +=, -=, *=, /=, &=, |=
Addition/Plus (+) Operator
The ‘+’ operator is used to append one string to another, or to add two integer values together.
Adding a number to a string will produce a string with the number (as text) appended to the end. Adding
a string to a number results in just the number (unless the string contains a value that can be converted to
a number).
For example:
This expression...
... resolves to this value.
3+4
7
“Hello”+” “+”There”
“Hello There”
“Hello”+3
“Hello3”
3+”Hello”
3
3+”6”
9