On Thursday, 20 August 2015 at 18:04:00 UTC, Steven Schveighoffer
wrote:
On 8/20/15 1:50 PM, Steven Schveighoffer wrote:
The "truthiness" of an array says it's true ONLY if both the
pointer and
length are 0.
Ugh, *false* only if they are both 0. If either are not zero,
then it's true.
-Steve
In other words, it's true when the pointer is not null. i.e. in
the context of boolean evaluation, it has the semantics of
string.ptr
It's just making the concept of an empty array a grey cloud.
Consider this:
string a = "";
string b;
writeln(a ? "a" : "null");
writeln(b ? "b" : "null");
writeln(a.idup ? "adup" : "null");
writeln(b.idup ? "bdup" : "null");
Output:
a
null
null
null
What?