Optional.opEquals

Compare two optionals or an optional with some value

  1. bool opEquals(None )
  2. bool opEquals(Optional!U rhs)
  3. bool opEquals(U rhs)
  4. bool opEquals(R other)
    struct Optional(T)
    const
    bool
    opEquals
    (
    R
    )
    (
    auto ref R other
    )
    if (
    from.std.range.isInputRange!R
    )

Return Value

Type: bool

- If the two are optionals then they are both unwrapped and compared. If either are empty this returns false. And if compared with none and there's a value, also returns false

auto a = some(3);
a == some(2); // false
a == some(3); // true
a == none; // false

Meta