if(arr) now a warning
Byron Heads via Digitalmars-d
digitalmars-d at puremagic.com
Thu Apr 30 05:34:42 PDT 2015
On Wed, 29 Apr 2015 22:44:22 -0400, Steven Schveighoffer wrote:
> On 4/29/15 8:35 PM, Martin Nowak wrote:
>> Occasionally I'm using if (auto ary = func()), despite the fact that
>> the semantics are wrong, but it's nice and short and works as long a
>> func always returns null instead of empty slices.
>
> I wonder if it's possible to fix this, as it is, IMO, the only
> legitimate drawback of this change. Could we make the following work?
>
> if((auto ary = func()).length)
>
> -Steve
I would have though this would work:
if(auto x = foo(), !x.empty)
More information about the Digitalmars-d
mailing list