Nullable.get

Gets the value. this must not be in the null state. This function is also called for the implicit conversion to T.

Preconditions: isNull must be false.

struct Nullable(T, T nullValue)
@property ref inout
inout(T)
get
()

Return Value

Type: inout(T)

The value held internally by this Nullable.

Examples

import std.exception : assertThrown, assertNotThrown;

Nullable!(int, -1) ni;
//`get` is implicitly called. Will throw
//an error in non-release mode
assertThrown!Throwable(ni == 0);

ni = 0;
assertNotThrown!Throwable(ni == 0);

Meta

Suggestion Box / Bug Report