Andrej Mitrovic <[email protected]> wrote:
Actually I'm having a hard time understanding this:
void main()
{
string s = "";
assert(s); // pass, but why?
assert(s !is null); // pass
}
void main()
{
string s = "".idup;
assert(s); // fail
assert(s !is null); // pass
}
Try adding writeln( s.ptr ); in there. Should probably give you an
indication of what is and == do.
Answer:
== null:
Length
P ==0 !=0
t ==0 T F
r !=0 T F
is null:
Length
P ==0 !=0
t ==0 T F
r !=0 F F
Where T and F stand for true and false, respectively.
So likely, idup on an empty string returns an array with null ptr and
0 length, while "" is 'allocated' in the data segment, and thus given a
ptr value.
--
Simen