The OpenD Programming Language

Algebraic.get

Gets the value if not null. If this is in the null state, and the optional parameter fallback was provided, it will be returned. Without fallback, calling get with a null state is invalid.

When the fallback type is different from the Nullable type, get(T) returns the common type.

  1. auto get()
  2. inout(AllowedTypes[1]) get()
    struct Algebraic(T__...)
    ref return inout
    static if(is(AllowedTypes[0] == typeof(null)))
    static if(AllowedTypes.length == 2)
    inout(AllowedTypes[1])
    get
    ()
  3. inout(AllowedTypes[1]) get [@property setter]
  4. auto ref get()
  5. template get(RetTypes...)
  6. alias get(Kind kind) = get!(AllowedTypes[kind])
  7. alias get(immutable(char)[] kind) = get!(__traits(getMember, Kind, kind))
  8. auto ref get()

Return Value

Type: inout(AllowedTypes[1])

The value held internally by this Nullable.

Examples

enum E { a = "a", b = "b" }
Nullable!E f = E.a;
auto e = f.get();
static assert(is(typeof(e) == E), Nullable!E.AllowedTypes.stringof);
assert(e == E.a);

assert(f.get(E.b) == E.a);

f = null;
assert(f.get(E.b) == E.b);

Meta