...
| Table of Contents | ||||
|---|---|---|---|---|
|
Arithmetic and Conditional Operators
...
- getAt() and setAt() for the subscript operator (e.g. foo[1])
- Range Operator (..) - see Collections Collections#Collections-Ranges
- Membership Operator (in)
Elvis Operator (?: )
...
For more details, see: Regular Expressions
Table of Operators
Operator Name | Symbol | Description |
|---|---|---|
Spaceship | <=> | Useful in comparisons, returns -1 if left is smaller 0 if == to right or 1 if greater than the right |
Regex find | =~ | Find with a regular expresion? See Regular Expressions |
Regex match | ==~ | Get a match via a regex? See Regular Expressions |
.@ | Can be used to override generated properties to provide access to a field | |
*. | Used to invoke an action on all items of an aggregate object | |
Spread Java Field | *.@ | Amalgamation of the above two |
Method Reference | .& | Get a reference to a method, can be useful for creating closures from methods |
asType Operator | as | Used for groovy casting, coercing one type to another. |
Membership Operator | in | Can be used as replacement for collection.contains() |
Identity Operator | is | Identity check. Since == is overridden in Groovy with the meaning of equality we need some fallback to check for object identity. |
?. | returns nulls instead of throwing NullPointerExceptions | |
?: | Shorter ternary operator |