Collection

protocol Collection : Sequence
  • Obtains the first element of this collection or Option.none.

    Declaration

    Swift

    public var firstOrNone: Option<Element> { get }
  • Obtains the first element of this collection that matches a predicate.

    Declaration

    Swift

    public func firstOrNone(_ predicate: (Element) -> Bool) -> Option<Element>

    Parameters

    predicate

    Filtering predicate.

    Return Value

    First element that matches the predicate or Option.none.

  • Returns an element if it is the single one in this collection or Option.none

    Declaration

    Swift

    public var singleOrNone: Option<Element> { get }
  • Returns an element if it is the single one matching a predicate.

    Declaration

    Swift

    public func singleOrNone(_ predicate: (Element) -> Bool) -> Option<Element>

    Parameters

    predicate

    Filtering predicate.

    Return Value

    A value if it is the single one matching the predicate, or Option.none.