C++17 std::optional
C++17 std::optional
March 1, 2022
Template Deduction Guide
Template Deduction Guide
March 15, 2022

March 8, 2022

What is Elvis Operator (?:)

Elvis operator(?:) is named after its resemblance to Elvis Presley's famous hair. Even though it is not the "king" of operators, the operator is present in many languages such as C, Kotlin, Groovy, and Cold Fusion. You can use this operator to safeguard against null values and to provide default assignment values when the primary option fails.

x = a ? : b
//is equivalent to the 
following expression:
x = if(a == null) b else a
What is Elvis Operator (?:)
This website uses cookies to improve your experience. By using this website you agree to our Data Privacy Statement
Read more