This article is about the use of a ?: operator as a binary operator. For use as a ternary operator, see ?:.
In certain computer programming languages, the Elvis operator, often written ?:, is a binary operator that returns the evaluated first operand if that operand evaluates to a value likened to logically true (according to a language-dependent convention, in other words, a truthy value), and otherwise returns the evaluated second operand (in which case the first operand evaluated to a value likened to logically false, in other words, a falsy value). 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 expression 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.[1]
A similar operator is the null coalescing operator, where the boolean truth(iness) check is replaced with a check for non-null instead. This is usually written ??, and can be seen in languages like C#[2] or Dart.[3]
^Joyce Farrell (7 February 2013). Java Programming. p. 276. ISBN 978-1285081953. The new operator is called Elvis operator because it uses a question mark and a colon together (?:); if you view it sideways, it reminds you of Elvis Presley.
^"?? Operator". C# Reference. Microsoft. Retrieved 5 December 2018.
semantics. The notation of the Elvisoperator was inspired by the ternary conditional operator, ? :, since the Elvisoperator expression A ?: B is approximately...
conditional if operator used as x ? x : y, but like the binary Elvisoperator used as x ?: y, the null coalescing operator is a binary operator and thus evaluates...
inline if function Null coalescing operator, ?? operatorElvisoperator, ?:, or sometimes ?., as a shorthand binary operator Conditioned disjunction, equivalent...
navigation operator (also known as optional chaining operator, safe call operator, null-conditional operator, null-propagation operator) is a binary operator that...
operator in computer programming, typically notated as or or | The short-circuit operator or, notated or, ||, or or else Elvisoperator, an operator in...
-$value; } Since PHP 5.3 supports Elvisoperator (?:) in which it is possible to omit the middle part of the ternary operator. $c = $a ?: $b; /* Equivalent...
2016). "Elvis Costello 10 of the Best". The Guardian. "Elvis Costello Official Charts". Official Charts. Thomson 2004, pp. 125–126. Costello, Elvis (2002)...
2012. Elvis (text editor) Elvisoperator, a type of conditional operator in programming Elvis, a code name for the Nokia Lumia 1020 17059 Elvis, an asteroid...
comparison), Diamond operator <> (for type hinting) and Elvisoperator ?: (a shortened ternary operator). Usually, emoticons in Western style have the eyes...
Presley to his son Kurt's Elvis Presley in the television movie, Elvis (1979). Kurt, as a child actor, had appeared with the real Elvis in the film It Happened...
the time performing as D.P. Costello, Costello changed his name to Elvis after Elvis Presley at the suggestion of the label, and adjusted his image to...
Muhammad Ali, and CORE Media Group's 85% stake in Elvis Presley Enterprises (which includes the estate of Elvis Presley, likeness rights, and music publishing...
Indiana Cape May, New Jersey Chattanooga, Tennessee Drummond Island, Michigan Elvis Stahr Harbor, Kentucky Exxon Terminal, East Providence, Rhode Island Eureka...
and Elvis Presley opened a new form of music. Phillips said of Presley: "Elvis cut a ballad, which was just excellent. I could tell you, both Elvis and...
work of noted architect George Awsumb. The school also has a connection to Elvis Presley, who graduated from the school in 1953. The school has numerous...
King's Ransom" January 22, 2014 (2014-01-22) 11.03 A life-size sculpture of Elvis is uncovered in rural Vermont; rare military memorabilia is found in New...
hosted two specials regarding Elvis conspiracy theories and his alleged sightings: The Elvis Files (1991) and The Elvis Conspiracy (1992). Bixby made...
Community College and placed on display at the Elvis Presley Memphis Museum. A licensed 1/16 toy replica of Elvis's tractor was produced by the Ertl Company...
medicine, then Elvis never died. This condition should clearly be false: the degree of Bill Gates has nothing to do with whether Elvis is still alive...
next day, as part of some major lineup changes, 95 Triple X began carrying Elvis Duran and the Morning Show. WXXX was the birthplace of many radio careers...
where his quarry, an expert forger named Claude Purcell, is enrolled in an Elvis impersonation contest and takes on a gang that is forcing Purcell to forge...
radio and digital personality Elvis Duran was announced as her sponsor. Duran hosts the morning talk radio show, Elvis Duran and the Morning Show. On-air...