Andrei Alexandrescu wrote:
bearophile wrote:
One of those five precios things is the "Elvis" operator: Exp1 ?:
Exp2
That means: If Exp1 is non-null, use that, otherwise evaluate and use
Exp2
Adding it to D looks easy, but is such operator so important to be in
the list of the only 5 things to add? I don't currently feel the need
of it.
I agree. D has it already by the way:
Exp1 && Exp2;
You may want to re-read the spec on that. "The result type of an
AndAndExpression is bool, unless the right operand has type void, when the
result is type void."
So the result will never be a pointer or object reference.
http://www.digitalmars.com/d/1.0/expression.html#AndAndExpression (The text
appears to be identical for D2)