Hi! Is the following possible without using macros or wrapping the arrays in reference types?
Let's say I have these
var a: [Int] = []
var b: [Bool] = []
var c: [String] = []
And then I want to do this:
a.removeAll()
b.removeAll()
c.removeAll()
But I want to write it in a less repetitive way, along the lines of:
withEach(&a, &b, &c) { $0.removeAll() }
The exact solution doesn't matter, the goal is just to have a short and readable way to call a common mutating method an all three (or 4 or 5 ...) variables. In this example the method happens to be RangeReplaceableCollection
's removeAll
.