orDefault

Returns the deref value from this optional or TypeFromOptional!T.init if set to none.

orDefault
(
T
)
(
scope return T v
)
if (
isVariant!T
)

Examples

static assert(is(TypeFromOptional!OptionalJsonValue == JsonValue));
OptionalJsonValue someJson;
assert(someJson.orDefault == JsonValue.init);
someJson = JsonValue(5);
assert(someJson.orDefault == JsonValue(5));

static assert(is(TypeFromOptional!(Optional!int) == int));
Optional!int someInt;
assert(someInt.orDefault == 0);
someInt = 5;
assert(someInt.orDefault == 5);

Meta