WebGlossary.info
Elvis operator
- A binary operator, often written
?:
, that returns its first operand if that operand evaluates to a true value, and otherwise evaluates and returns its second operand. This is identical to a short-circuit or
with “last value” semantics. The notation of the Elvis operator was inspired by the ternary conditional operator, ? :
, since the Elvis operator expression A ?: B
is approximately equivalent to the ternary conditional A ? A : B
. The name “Elvis operator” refers to the fact that when its common notation, ?:
, is viewed sideways, it resembles an emoticon of Elvis Presley with his signature hairstyle. ← Wikipedia
- Previous term: else
- Next term: Em
- Random term: Infrastructure as a service