Hey guys, got a question about filtering on collec...
# announcements
w
Hey guys, got a question about filtering on collections. Let’s say I have a list that I will filter down based on some criteria and process only a subset of elements:
Copy code
val myList = List<MyClass>(...)
myList.filter(it.date > cutoffDate)
    .filter(it.type != "excludedType")
    .forEach {
        // process the subset that went through the filters
        ...
    }
For those elements that got filtered out in the above example, I also want to log them (say by sending a message to an outside listener to ack that I got this element but it failed the filter). How do I do that in an idiomatic way?