For more details about how expressions are corced coerced to a boolean value, see: Groovy Truth.
The "Elvis operator" is a shortening of Java's ternary operator. One instance of where this is handy is for returning a 'sensible default' value if an expression resolves to
null. A simple example might look like this:
def genderdisplayName = user.malename ? "male"user.name : "femaleAnonymous" //traditional ternary operator usage def displayName = user.name ?: "Anonymous" // more compact Elvis operator - does same as above
Safe Navigation Operator (?.)