if(int a = 0) lowered to "if (int a = (int a = 1;) , a)" ?
Jonathan M Davis
newsgroup.d at jmdavisprog.com
Wed Aug 8 12:29:04 UTC 2018
On Wednesday, August 8, 2018 5:58:50 AM MDT aliak via Digitalmars-d-learn
wrote:
> Found this out while just looking at lowerings. Wondering if
> anyone knows the semantics involved here and where they are
> documented?
It's particularly useful when dealing with stuff like C functions that
return 0 on success or getting values from AAs. e.g.
if(auto value = key in aa)
{
}
> And, is there anyway to do it with multiple variables?
>
> I.e.
>
> if (int a = 0, int b = 0) {
> // ...
> }
I don't believe so.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list