ofNullable


Description:

public static Optional<T> ofNullable<T> (owned T value)

Creates an Optional from a nullable value. If the value is null, returns an empty Optional; otherwise wraps the value.

Example:

    string? name = "Alice";
var opt = Optional.ofNullable<string> (name);
assert (opt.isPresent ());

Parameters:

value

the possibly-null value.

Returns:

an Optional containing the value, or empty if null.