So, null arrays and empty arrays are always the same, except for an empty string, which is a valid non-nill array of characters with length 0, right?<br><br><div class="gmail_quote">On Mon, May 14, 2012 at 2:24 PM, simendsjo <span dir="ltr"><<a href="mailto:simendsjo@gmail.com" target="_blank">simendsjo@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Mon, 14 May 2012 12:08:17 +0200, Gor Gyolchanyan <<a href="mailto:gor.f.gyolchanyan@gmail.com" target="_blank">gor.f.gyolchanyan@gmail.com</a>> wrote:<br>

<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi! I have a small question:<br>
Is the test for a null array equivalent to a test for zero-length array?<br>
This is particularly interesting for strings.<br>
For instance, I could return an empty string from a toString-like function<br>
and the empty string would be printed, but If I returned a null string,<br>
that would indicate, that there is no string representation and it would<br>
cause some default string to be printed.<br>
So, the question is, if a null array is any different from an empty array?<br>
<br>
</blockquote>
<br></div></div>
This passes. null and [] is a null string, but "" gives a non-null string. Tested on dmd-head and 2.059.<br>
<br>
void main() {<br>
    string s1 = null;<br>
    assert(s1 is null);<br>
    assert(s1.length == 0);<br>
    assert(s1.ptr is null);<br>
    assert(s1 == []);<br>
    assert(s1 == "");<br>
<br>
    string s2 = [];<br>
    assert(s2 is null);<br>
    assert(s2.length == 0);<br>
    assert(s2.ptr is null);<br>
    assert(s2 == []);<br>
    assert(s2 == "");<br>
<br>
    string s3 = "";<br>
    assert(s3 !is null);<br>
    assert(s3.length == 0);<br>
    assert(s3.ptr !is null);<br>
    assert(s3 == []);<br>
    assert(s3 == "");<br>
}<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br>