optional

Shortcut on top of Optional to created defined value, uses IFTI to reduce the noise

optional
(
T
)
()

Parameters

value T

value to wrap into Optional

Return Value

Type: Optional!(T)

wrapped value

Examples

Optional!(int) foo ( bool x )
{
    if (x)
        return optional(42);
    else
        return Optional!(int).undefined;
}

foo(true).visit(
    ()              { test(false); },
    (ref int value) { test(value == 42); }
);

foo(false).visit(
    ()              { },
    (ref int value) { test(false); }
);

Meta