if(arr) now a warning

Daniel Murphy via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 10 06:47:19 PDT 2015


"ketmar"  wrote in message news:mg8hda$2rs$12 at digitalmars.com...

> >
> > 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.
>
> isn't it a compiler task to track types? ranges can be empty, arrays can
> be empty. i can't see why one should remember that their emptiness if
> somehow different.

Nobody said you have to remember anything, it's a style choice.

It's like this code:

uint x;

if (x > 0) {}

if (x != 0) {}

Both of those if conditions are the same, but you'll use one or the other 
depending on context. 



More information about the Digitalmars-d mailing list