Groovy 8 – Precedence
Precedence is showing the order in which operators are evaluated while the code runs.
The table below lists all Groovy operators in order of precedence.
Level | Operator(s) | Name(s) |
---|---|---|
1 | new() | object creation, explicit parentheses |
(), {}, [] | method call, closure, literal list/map | |
., .&, .@ | member access, method closure, field/attribute access | |
?.*, *., *: | safe dereferencing, spread, spread-dot, spread-map | |
~, !, (type) | bitwise negate/pattern, not, typecast | |
[], ++, -- | list/map/array index, post increment/decrement | |
2 | ** | power |
3 | ++, --, +, - | pre increment/decrement, unary plus, unary minus |
4 | *, /, % | multiply, divide, remainder |
5 | +, - | addition, subtraction |
6 | <<, >>, >>>, .., ..< | left/right (unsigned) shift, inclusive/exclusive range |
7 | <, <=, >, >=, in, instanceof, as | less/greater than/or equal, in, instanceof, type coercion |
8 | ==, !=, <=> | equals, not equals, compare to |
9 | =~, ==~ | regex find, regex match |
& | binary/bitwise and | |
10 | ^ | binary/bitwise xor |
11 | | | binary/bitwise or |
12 | && | logical and |
13 | || | logical or |
14 | ? : | ternary conditional |
15 | ?: | elvis operator |
=, **=, *=, /=, %=, +=, -= | various assignments | |
<<=, >>=, >>>=, &=, ^=, |= |
Source: Groovy Operators
I have left the table intact showing all possible operators that are allowed in Groovy programming language.
I have highlighted the ones we discussed in the previous posts.
However, keep in mind that while scripting in application composer, you will not be using most of these operators.