> On 18 Jan 2017, at 09:00, Anton Zhilin via swift-evolution 
> <swift-evolution@swift.org> wrote:
> 
> While realizing that this name can cause confusion, I'd still prefer 
> `reduce(mutating:_:)`, because it looks like the only readable option to me.
> Whatever name will be picked, I agree that traditional reduce without 
> mutation should retain its name.
> 
> 2017-01-18 5:17 GMT+03:00 Xiaodi Wu via swift-evolution 
> <swift-evolution@swift.org <mailto:swift-evolution@swift.org>>:
> 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`. 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

I suppose as a second-choice I’d go for accumulate(into: with:):

[1, 2, 3].accumulate(into: 0, with: +=) 

even [1, 2, 3].accumulate(into: 0, with: -=) doesn’t look so bad IMO.

- Karl
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to