filter


Description:

public Optional<T> filter (owned PredicateFunc<T> predicate)

If a value is present and matches the predicate, returns this Optional; otherwise returns an empty Optional.

Example:

    var opt = Optional.of<string> ("hello");
var filtered = opt.filter ((s) => { return s == "hello"; });
assert (filtered.isPresent ());

Parameters:

predicate

the condition to test.

Returns:

this Optional if matching, otherwise empty.