> On 18 Jan 2017, at 12:26, Xiaodi Wu via swift-evolution
> <[email protected]> wrote:
>
> Thought: if the idea is performance and not drop-in replacement, why force
> the user to incur two copies? If the initial value were inout, this function
> would be more unambiguous even without a new name, and at _worst_ the user
> has to declare a variable with var, a worthwhile trade-off to save two copies.
That’s what I thought also until just now, but then why wouldn’t you just use a
for … in loop?
i.e. instead of
var foo = 0
let bar: [SomeType] = ...
bar.reduce(mutating: &foo, someFunction)
You would write
var foo = 0
let bar: [SomeType] = …
for e in bar {
someFunction(&foo, e)
}
which is a bit more readable IMO
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution