Optional.opCast

Provides a mechanism to allow usage in boolean expressions.

struct Optional(T)
const
bool
opCast
(
B : bool
)
()

Return Value

Type: bool

true if non-null, false if null

auto optInt = Optional!int.empty();
assert(!optInt);
auto optStr = Optional!string.of("Hello");
assert(optStr);