Checking if a string is null

Max Samukha samukha at voliacable.com.removethis
Tue Jul 24 22:25:21 PDT 2007


Using '== null' and 'is null' with strings gives odd results (DMD
1.019):

void main()
{
	char[] s;

	if (s is null) writefln("s is null");
	if (s == null) writefln("s == null");		
}

Output:
s is null
s == null

----

void main()
{
	char[] s = "";

	if (s is null) writefln("s is null");
	if (s == null) writefln("s == null");		
}

Output:
s == null

----

Can anybody explain why s == null is true in the second example?







More information about the Digitalmars-d-learn mailing list