Forbid dynamic arrays in boolean evaluation contexts

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Mar 25 10:12:54 PDT 2013


On Mon, Mar 25, 2013 at 08:46:42PM +0400, Dmitry Olshansky wrote:
> 25-Mar-2013 20:43, Phil Lavoie пишет:
> >I do believe that, in any case, this form is best:
> >if( arr !is null && !arr.empty )
> >
> 
> Now write that one thousand times and count the typos.
[...]

What's wrong with just writing: if (arr.length > 0) ?  .length will
return 0 both when arr is null and when it's non-null but empty.


T

-- 
Heads I win, tails you lose.


More information about the Digitalmars-d mailing list