Optional
Object Hierarchy:
Description:
A container object which may or may not contain a value.
Namespace: Gpseq
Package: gpseq-1.0
Content:
Properties:
- public bool is_present { get; }
Whether or not there is a value present.
- public G value { get; }
The value held by this optional.
- public Type value_type { get; }
The type of the value.
Creation methods:
- public Optional ()
- public Optional.empty ()
Creates an empty optional instance.
- public Optional.of (owned G value)
Creates an optional instance with the given value present.
Methods:
- public Optional<G> filter (Predicate<G> pred)
If a value is present and matches the given predicate, returns an optional containing the value, otherwise returns an empty optional.
- public void if_present (Func<G> consumer)
If a value is present, performs the given consumer function with the value.
- public Optional<A> map<A> (MapFunc<Optional<A>,G> mapper)
If a value is present, performs the mapper function with the value, and returns the result. Otherwise returns an empty optional.
- public G or_else (G other)
If a value is present, returns the value, otherwise returns the given other.
- public G or_else_fail ()
If a value is present, returns the value, otherwise fails with GLib.error.
- public G or_else_get (SupplyFunc<G> supplier)
If a value is present, returns the value, otherwise returns the result produced by the supply function.
- public G or_else_throw (SupplyFunc<Error>? error_supplier = null) throws Error
If a value is present, returns the value, otherwise throws an error produced by the supply function -- or an OptionalError.NOT_PRESENT error if the function is not specified.
- public string to_string ()
Inherited Members:
All known members inherited from class GLib.Object