Nullable.opAssign

If value is null, sets this to null, otherwise assigns value.get to the internally-held state. If the assignment succeeds, this becomes non-null.

  1. void opAssign(T value)
  2. void opAssign(Nullable!T value)
    struct Nullable(T)
    void
    opAssign
    ()

Parameters

value Nullable!T

A value of type Nullable!T to assign to this Nullable.

Examples

If this Nullable wraps a type that already has a null value (such as a pointer), then assigning the null value to this Nullable is no different than assigning any other value of type T, and the resulting code will look very strange. It is strongly recommended that this be avoided by instead using the version of Nullable that takes an additional nullValue template argument.

//Passes
Nullable!(int*) npi;
assert(npi.isNull);

//Passes?!
npi = null;
assert(!npi.isNull);

Meta