creates a new sequence with every item of the source sequence for which the predicate function
returns a truthy/falsy value, optionally narrowing the type of the returned iterable (if a type-guard
predicate is supplied)
a new (possibly shorter) sequence with some items filtered away.
If a type-guard (i.e. function returns something like val is S) is supplied for pred, then the
resulting sequence will be narrowed to Iterable<S>
Type Parameters
T
S
Parameters
pred: TypeGuardPredicate<T, S>
a function that returns a truthy value to signal inclusion or a falsy value to exclude.
Alternatively a type-guard function can be supplied
creates a new sequence with every item of the source sequence for which the predicate function returns a truthy/falsy value, optionally narrowing the type of the returned iterable (if a type-guard predicate is supplied)
Remarks
deferred version of _filter
Returns
a new (possibly shorter) sequence with some items filtered away. If a type-guard (i.e. function returns something like
val is S
) is supplied forpred
, then the resulting sequence will be narrowed toIterable<S>