Re: Does D have an equvalent of: if (auto = expr; expr)

2020-02-07 Thread mark via Digitalmars-d-learn
Thanks for the excellent replies.

Re: Does D have an equvalent of: if (auto = expr; expr)

2020-02-07 Thread Basile B. via Digitalmars-d-learn
On Friday, 7 February 2020 at 08:52:44 UTC, mark wrote: Some languages support this kind of thing: if ((var x = expression) > 50) print(x, " is > 50") Is there anything similar in D? Yes assuming that the expression is bool evaluable. This includes - pointers: `if (auto p =

Re: Does D have an equvalent of: if (auto = expr; expr)

2020-02-07 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Friday, 7 February 2020 at 08:52:44 UTC, mark wrote: Some languages support this kind of thing: if ((var x = expression) > 50) print(x, " is > 50") Is there anything similar in D? Yes and no. It only works for bools or things that convert to bool. You might have seen: string[string]

Does D have an equvalent of: if (auto = expr; expr)

2020-02-07 Thread mark via Digitalmars-d-learn
Some languages support this kind of thing: if ((var x = expression) > 50) print(x, " is > 50") Is there anything similar in D?