Thanks for that thorough and careful explanation.
Since I'm trying to learn to write D in good style and want my
code to be reliable and maintainable, I've now switched to using
"" rather than null.
On Tuesday, February 4, 2020 12:33:42 AM MST mark via Digitalmars-d-learn
wrote:
> I have just discovered that D seems to treat empty and null
> strings as the same thing:
>
> // test.d
> import std.stdio;
> import std.string;
> void main()
> {
> string x = null;
> writeln("x = \"",
On Tuesday, 4 February 2020 at 07:44:08 UTC, mark wrote:
Just found this post by Mark Parker that explains:
https://forum.dlang.org/post/gvveit$10i5$1...@digitalmars.com
I recommend using Nullable from
https://dlang.org/phobos/std_typecons.html#Nullable if you want
to explicitly allow a non-v
Just found this post by Mark Parker that explains:
https://forum.dlang.org/post/gvveit$10i5$1...@digitalmars.com
// test.d
import std.stdio;
import std.string;
void main()
{
report(null, "null");
report("");
report("x");
}
void report(const string x, const string name=null) {
w
I have just discovered that D seems to treat empty and null
strings as the same thing:
// test.d
import std.stdio;
import std.string;
void main()
{
string x = null;
writeln("x = \"", x, "\"");
writeln("null = ", x == null);
writeln("\"\"= ", x == "");
writeln("empty