In certain computer programming languages, the Elvis operator, often written
?:, is a binary operator that returns its first operand if that operand evaluates to a true value, and otherwise evaluates and returns its second operand.
For example in Kotlin,
foo ?: bar will yield
foo is not
bar if otherwise.
Seeing how few languages support this, made me wonder: why don't more languages adopt this operator? AFAIK, short-circuit or
|| yields the same for some languages, but in C for example, the result of
|| will always be a boolean, so it won't work. Also, the Elvis operator looks more concise than short-circuit or
|| and the ternary counterpart:
A ? A : B.
So why is it not more common?