Function Name.this

Creates a new Name using the provided namespace if the name does not have one.

this (
  string name,
  string namespace
) @safe;

Example

Name name1 = new Name("bob", null);
assert(name1.name == "bob" && name1.namespace is null && name1.fullname == "bob");
Name name2 = new Name("bob", "");
assert(name2.name == "bob" && name2.namespace is null && name2.fullname == "bob");
Name name3 = new Name("bob", "com.example");
assert(name3.name == "bob" && name3.namespace == "com.example"
    && name3.fullname == "com.example.bob");
// If the name contains a namespace already, the provided one will be ignored.
Name name4 = new Name("com.example.bob", "org.funny");
assert(name4.name == "bob" && name4.namespace == "com.example"
    && name4.fullname == "com.example.bob");

// Without a name, the namespace is ignored.
Name name5 = new Name(null, "com.example");
assert(name5.name is null && name5.namespace is null && name5.fullname is null);