In the interests of readability, code that can be simplified should be simplified. When you would like to filter elements of iterable by some type,
it’s more concise to use the method whereType()
. This approach improves readability and is less error-prone.