Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

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 false or null. A simple example might look like this:

Code Block
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 (?.)

...