I am probably missing something very obvious: How do I efficiently filter and iterate through the entries of a HashMap in Kotlin?
I want to do the following:
myMap.filterValues{ someCondition }.forEach { doSomethingWithTheEntry }
How can I avoid the creation of intermediate objects? filterValues will create a HashMap, which is not really needed here.
I could of course write
myMap.forEach { if(someCondition) doSomethingWithTheEntry }
but the functional-style filter approach looks more elegant.