Nullable.opEquals

If they are both null, then they are equal. If one is null and the other is not, then they are not equal. If they are both non-null, then they are equal if their values are equal.

  1. bool opEquals(const(typeof(this)) rhs)
    struct Nullable(T)
    const
    bool
    opEquals
    ()
    (
    auto ref const(typeof(this)) rhs
    )
  2. bool opEquals(const(U) rhs)

Examples

1 Nullable!int empty;
2 Nullable!int a = 42;
3 Nullable!int b = 42;
4 Nullable!int c = 27;
5 
6 assert(empty == empty);
7 assert(empty == Nullable!int.init);
8 assert(empty != a);
9 assert(empty != b);
10 assert(empty != c);
11 
12 assert(a == b);
13 assert(a != c);
14 
15 assert(empty != 42);
16 assert(a == 42);
17 assert(c != 42);

Meta

Suggestion Box / Bug Report