Idea: mutatingForEach for Collections

This discussion has come up before. See In-place map for MutableCollection.
I'm in favor of the idea and don't have a strong opinion on its name.

Supporting this functionality at the language level has also come up:

for inout element in sequence {
    // ...
}

Both can exist (as for-in and forEach do), and I don't mean to imply that for-inout's implementation should preclude the inclusion of the proposed method—but it's relevant to discussion here.

8 Likes