Project Elvis

Ola Fosheim Grøstad ola.fosheim.grostad+dlang at gmail.com
Sun Oct 29 16:18:43 UTC 2017


On Sunday, 29 October 2017 at 14:37:57 UTC, Jonathan M Davis 
wrote:
> everything, but I could have missed something). As proposed 
> thus far, the Elvis operator is just the ternary operator where 
> the condition is reused as the first branch, so having it work 
> with opCast fits in perfectly with everything else.

I understand that it is being defined as a short hand for the 
ordinary ternary operator, but if you look at the use context the 
elvis-operator tend to be used to filter out invalid state.

So if casting to bool would test for validity then it would make 
more sense, but that is not the general case...

> What would you be looking to do that does not fit in with this?

I think it would be better to have a test for validity and use 
that for substituting in default values (which is what the elvis 
operator is typically used for).



More information about the Digitalmars-d mailing list