I’d have found this useful on several occasions — far more useful than forEach
. I believe I’ve called it mapInPlace
, as the prior discussion proposed. But modifyEach
also strikes me just fine.
I’d also very much like to have a filterInPlace
to go with it. The implementation of that method allows nice optimizations for specific collection types that are difficult to express generally, and even the simple array-only efficient implementation is easy to mess up.