Category Archives: Groovy

Safely get the first element from Groovy list

In Groovy it is safe to get the first collection element using standard bracket syntax even for empty collections. So you can use: list[0] For example: assert [][0] == null

Posted in Groovy | Tagged , | Leave a comment