This Week in D summarizes those long threads for you!

Timon Gehr via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Tue Aug 25 07:55:42 PDT 2015


On 08/24/2015 06:09 PM, Adam D. Ruppe wrote:
> the if(array) thread

> But, this can be surprising if you aren't used to it, since an empty array is not necessarily null:
> [] is null passes, since the literal avoids allocating for nothing,  but [1][1..$] is null fails,
> despite the array being empty, because the pointer is then set to the end of the input array.

void main(){
     assert([1][1..$] is null);
}

You forgot to take into account constant folding.


More information about the Digitalmars-d-announce mailing list