Do you think if statement as expression would be nice to have in D?

Nick Treleaven nick at geany.org
Sat Jun 4 16:15:26 UTC 2022


On Saturday, 4 June 2022 at 11:35:41 UTC, user1234 wrote:
> ```
> const char = if (current < input.len)
>             input[current]
>         else
>             break;
> ```
>
> - So the `break` expression has a type ? And this type is 
> compatible with the typê of `input[current]` ? wut ?

Just like `throw` is an expression in D now. It's type is 
noreturn, which implicitly converts to any type.


More information about the Digitalmars-d mailing list