-
Notifications
You must be signed in to change notification settings - Fork 1
Syntax Quick Reference
Alex Crome edited this page Aug 1, 2019
·
17 revisions
#set($variable = EXPRESSION)
#set($variable.Property = EXPRESSION)
#if(EXPRESSION) ... #end
#if(EXPRESSION) ... #else ... #end
#if(EXPRESSION) ... #elseif(EXPRESSION) ... #else ... #end
$variable
$variable.Property
$variable.Method(...)
$variable[...] (Index access)
$!silentReference
${formalReference}
$!{silentFormalReference}
##End of line comment
#* Block comment (may span multiple lines) *#
| Type | Example Syntax |
|---|---|
| Integer |
1 -74
|
| Decimal |
3.142 -2.72
|
| Boolean Literal |
true false
|
| String | 'Hello World' |
| Interpolated String | "Hello $name" |
| Reference: |
$variable $variable.Property $variable.Method(...) $variable.Property.Method(...).. $variable[...]
|
| List |
[] [$expression] [1, $foo, "Hello", ...]
|
| Range |
[-2..2] [1..$count]
|
| Dictionary | { key: 'value', otherKey: $value} |
| Parenthesised | (...) |
| Maths |
1 + 2.2 3 - 6 4 * -5 6 / 3 5 % 3
|
| Logical |
$a && $b `$c |
| Equality |
$a == $b $c != 'hello'
|
| Comparison |
$i > 0 10 < $x 1.5 >= 4.9 $x <= $y
|
| Not | !$bar |
Highest precedence at the top
| Category | Operators |
|---|---|
| Primary | (...) |
| Unary | ! |
| Multiplicative |
* / %
|
| Additive |
+ -
|
| Relational |
< > <= >= lt gt le ge
|
| Equality |
== != eq ne
|
| And |
&& and
|
| Or |
|| or
|