DWScript provides several operators familiar to developers coming from C-family languages.
Compound assignment operators combine an arithmetic operation with an assignment. They are shorthand for variable := variable <op> expression.
| Operator | Equivalent | Description |
|---|---|---|
+= |
a := a + b |
Add and assign |
-= |
a := a - b |
Subtract and assign |
*= |
a := a * b |
Multiply and assign |
/= |
a := a / b |
Divide and assign |
var a := 10;
a += 5;
PrintLn(a); 15
For convenience, DWScript supports C-style symbols for equality and inequality.
| Operator | Pascal Equivalent | Description |
|---|---|---|
== |
= |
Equality |
!= |
<> |
Inequality |
var x := 10;
if (x == 10) then
PrintLn('Matches');
if (x != 0) then
PrintLn('Non-zero'); Matches Non-zero