filterToSet

inline fun <T> Iterable<T>.filterToSet(destination: MutableSet<T> = mutableSetOf(), predicate: (T) -> Boolean): Set<T>(source)

Filters the receiver iterable and adds the matching elements to a set.

This is a shorthand for filterTo(destination, predicate) where destination is a set.

Receiver

The iterable to be filtered.

Return

A set containing elements from the receiver iterable that match the predicate.

Parameters

destination

The destination set where the elements that match the predicate are placed. By default, it is an empty mutable set.

predicate

A function that determines if an item should be included in the output set.