if(arr) now a warning
ketmar via Digitalmars-d
digitalmars-d at puremagic.com
Fri Apr 10 05:58:18 PDT 2015
On Fri, 10 Apr 2015 20:30:16 +1000, Daniel Murphy wrote:
> "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.
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150410/1a4613bf/attachment.sig>
More information about the Digitalmars-d
mailing list