How to workaround assignment not allowed in a condition?

user1234 user1234 at 12.de
Wed Oct 12 12:21:38 UTC 2022


On Wednesday, 12 October 2022 at 02:15:55 UTC, Steven 
Schveighoffer wrote:
> Porting some C code to D
>
> This results in an error:
>
> ```d
> int x;
> while(!(x = 5)) { break; }
> ```
> Error is: assignment cannot be used as a condition, perhaps 
> `==` was meant?
> ...

I think D should relax the restriction and allows the AssignExp 
as condition they are enclosed between parentheses.


More information about the Digitalmars-d-learn mailing list