Do you think if statement as expression would be nice to have in D?
Ali Çehreli
acehreli at yahoo.com
Sat Jun 4 06:49:36 UTC 2022
On 6/3/22 11:33, Jack wrote:
> Rust does support it like that:
>
> ```rust
> const limit:i32 = 30;
> let n = 10;
> let mut r = if n > limit { "big" } else { "small "};
> println!("{} is {} than {}", n, r, limit);
> ```
>
> do you think would be nice that in D as well?
It is consistent with the rest of Rust because I think all blocks are
expressions in Rust. For example:
https://doc.rust-lang.org/reference/expressions/block-expr.html
Ali
More information about the Digitalmars-d
mailing list