Forbid dynamic arrays in boolean evaluation contexts
Dmitry Olshansky
dmitry.olsh at gmail.com
Mon Mar 25 14:11:56 PDT 2013
25-Mar-2013 21:09, Phil Lavoie пишет:
> On Monday, 25 March 2013 at 16:46:46 UTC, 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.
>>
>>> Peace,
>>> Phil
>
> A thousand? !arr.empty instead of arr.length? Was that your point?
That short path better be correct path in most cases and this form is
exactly in the opposite direction: treating if (arr) as if(arr.ptr)
Not to mention the following "idiom":
if( arr !is null && !arr.empty )
--
Dmitry Olshansky
More information about the Digitalmars-d
mailing list