October 15, 2018 Re: D Logic bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan Marler | On Thursday, 11 October 2018 at 23:17:15 UTC, Jonathan Marler wrote: > For example, the "Conditional operator" in D actually has a higher priority than an assignment, but in C++ it's the same and is evaluated right-to-left. So this expression would be different in C++ and D: > > a ? b : c = d > > In D it would be: > > (a ? b : c ) = d > > And in C++ would be: > > a ? b : (c = d) This is now deprecated: int b = 1, c = 1; 1 ? b : c = 0; Deprecation: `1 ? b : c` must be surrounded by parentheses when next to operator `=` https://dlang.org/changelog/2.082.0.html#cond_assign |
Copyright © 1999-2021 by the D Language Foundation