> On 18 Jan 2017, at 02:17, Xiaodi Wu via swift-evolution 
> <[email protected]> wrote:
> 
> A serious possibility would be: `reduce(mutableCopyOf: x) { ... }`.
> 
> It's verbose, but the nicer-looking `reduce(mutating: x) { ... }` is 
> incorrect since, as Charles pointed out to Dave, it's not `x` that's mutated 
> but rather a mutable copy of it, so it doesn't matter if `x` itself is 
> declared with `let` or `var`.

Why not also have that version?

var foo = 0
let bar: [SomeType] = ...

bar.reduce(mutating: &foo, someFunction) 

// foo now contains the reduced bar


> 
> 
> _______________________________________________
> swift-evolution mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to