The following table shows a summary of the built-in operators.
Operator | Result type | Description |
---|---|---|
not | Boolean | The unary not operator applies to a Boolean expression and performs a Boolean negation. It is equivalent to the Groovy ! operator. For example, the expression not TRUE yields FALSE. |
and && |
Boolean | Performs a short-circuit Boolean "and" operation. For example, the expression TRUE AND TRUE yields TRUE, and TRUE AND FALSE yields FALSE. |
or || |
Boolean | Performs a short-circuit Boolean "or" operation. For example, the expression TRUE OR FALSE yields TRUE, and FALSE AND FALSE yields FALSE. |
+ | Depends on types of left and right operands | When used with numeric types such as Integer, Float, BigDecimal performs an arithmetic addition. When used with operands of type String, performs a string concatenation. For full details see the Groovy website athttp://groovy.codehaus.org/Operators. |
< | Boolean | Performs a less-than comparison. For numeric types such as Integer, Float, and BigDecimal, this is a signed arithmetic comparison. It can also be used to compare strings, and to compare dates. For full details see the Groovy website. |
<= | Boolean | Performs a less-than-or-equal comparison. For numeric types such as Integer, Float, and BigDecimal, this is a signed arithmetic comparison. It can also be used to compare strings and dates. For full details see the Groovy website. |
> | Boolean | Performs a greater-than comparison. For numeric types such as Integer, Float, and BigDecimal, this is a signed arithmetic comparison. It can also be used to compare strings and dates. For full details see the Groovy website. |
>= | Boolean | Performs a greater-than-or-equal comparison. For numeric types such as Integer, Float, and BigDecimal, this is a signed arithmetic comparison. It can also be used to compare strings and dates. For full details see the Groovy website. |
= == |
Boolean | Performs an equals comparison. For numeric types such as Integer, Float, and BigDecimal, this is a signed arithmetic comparison. It can also be used to compare strings and dates. For full details see the Groovy website. |
!= | Boolean | Performs a not-equals comparison. For numeric types such as Integer, Float, and BigDecimal, this is a signed arithmetic comparison. It can also be used to compare strings and dates. For full details see the Groovy website. |
~ | Boolean | Performs a shell pattern match. The character "*" is a wildcard matching zero, one, or many characters. The character "?" matches any single character. Shell pattern matches are case-sensitive on UNIX, and not case-sensitive on Windows. Example: %name ~ '*.c' The example would return TRUE for names such as example.c or a.txt.c and return FALSE for names such as abc or a.cc. |
=~ | Boolean | Performs a regular expression match. The operand after =~ must be a string that is a valid regular expression. Regular expression matches are case-sensitive by default on all platforms, but can be made not case-sensitive using the (?i) option embedded in the pattern. Example: %name =~ '.*\\.c' The example would return TRUE for names such as example.c or a.txt.c and return FALSE for names such as abc or a.cc. For full details see the Groovy website. |