This was my first thought.
This is similar to the discussion about reduce(into:)
(Reduce with inout - #26 by Joe_Groff) - you could argue for another function also called forEach
with an inout
parameter, but that would probably be too much stress on the type-checker.
I wonder if we could do something like:
extension MutableCollection {
func forEach(_ perform: (inout Element)->Void)) { ... }
@available(*, unavailable)
func forEach(_ perform: (Element)->Void)) { ... }
}