Elvis operator (source code)

= Elvis operator
{wiki=Elvis_operator}

The Elvis operator is a shorthand syntax used in programming languages like Groovy, Kotlin, and others, to simplify null checks and handle default values. It allows you to return a value based on whether an expression is null or not, often making code cleaner and more concise. The operator itself is represented as \`?:\`. It functions as a way to express "if the value on the left is not null, return it; otherwise, return the value on the right.