Groovy Truth Add comment to Wiki View in Wiki Edit Wiki page Printable Version

Boolean expressions

Groovy supports the standard conditional operators on boolean expressions, e.g.:

In addition, Groovy has special rules for coercing non-boolean objects to a boolean value.


Empty collections are coerced to false.

Iterators and Enumerations

Iterators and Enumerations with no further elements are coerced to false.


Non-empty maps are coerced to true.


Matching regex patterns are coerced to true.


Non-empty Strings, GStrings and CharSequences are coerced to true.


Non-zero numbers are coerced to true.

Object references

Non-null object references are coerced to true.



Results of your search request can come from various sources: the Groovy website itself, the JIRA issues, the API documentation, as well as a few other interesting Groovy-related blogs.

  By  -  pages  -  views  - last modified