filterByType
FilterByType is a utility pattern that selects elements from a collection whose runtime type matches a specified type. It helps organize mixed data and enables type-specific processing without introducing ad hoc filtering logic throughout code. The function typically takes a collection and a type descriptor and returns a new collection composed only of items that satisfy the type criterion.
Implementation details vary by language. In dynamically typed languages, the type descriptor is usually a class
Common use cases include separating objects in a heterogeneous list into groups by their type, applying different
Caveats include ambiguity with inheritance where subclasses also match the type, potential performance costs from repeated