if(arr) now a warning

Daniel Murphy via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 10 03:30:16 PDT 2015


"Martin Nowak"  wrote in message 
news:lgjobvhvilvdymfatoje at forum.dlang.org...

> I've been thinking about moving std.array.empty to object. Then that could 
> more easily become the replacement idiom.
>
> if (arr) -> if (!arr.empty)
>
> It's much clearer and also what you need to write when you work with 
> ranges.

if (arr.length) is just as clear, and the same thing.

I use arr.length when I'm working with arrays, and .empty when working with 
general ranges.  I generally prefer not to mix the two. 



More information about the Digitalmars-d mailing list