Rant after trying Rust a bit

Adam D. Ruppe via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 22 13:59:06 PDT 2015


On Wednesday, 22 July 2015 at 20:43:04 UTC, simendsjo wrote:
> When "everything" is an expressions, you can write things like
>     auto a = if(e) c else d;
>
> In D you have to write
>     type a = invalid_value;
>     if(e) a = c;
>     else  a = d;
>     assert(a != invalid_value);


That's what the ternary expression is for:

auto a = e ? c : d;


Though the ternary is unnecessary with statements as expressions, 
common cases like this are handled.


More information about the Digitalmars-d mailing list