if(arr) now a warning

Martin Nowak via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 22 15:10:19 PDT 2015


Interesting trivia, I even found this bug in the documentation of the
first dmd release http://downloads.dlang.org/releases/0.x/0.100/dmd.100.zip.


Checking For Empty Strings

C++ strings use a function to determine if a string is empty:
	string str;
	if (str.empty())
		// string is empty
In D, an empty string is just null:
	char[] str;
	if (!str)
		// string is empty


Apparently it was later fixed to if (!str.length)
http://www.digitalmars.com/d/1.0/cppstrings.html.


More information about the Digitalmars-d mailing list