Sequence

protocol Sequence

This cool little extension comes straight from here: https://stackoverflow.com/a/55796671/879365

  • This allows us to sort through a sequence container of various instances, looking for ones that match a given protocol.

    Declaration

    Swift

    func filterForInstances<T>(of: T.Type) -> [T]

    Parameters

    of

    The type that we are filtering for.

    Return Value

    An Array of elements that conform to the given type.