Sum with Block

let array1: [Int8] = [127, 8, -128]
let array2: [Int8] = [127, -128, 8]
let set = Set(array1)
// print(array1.sum()) // traps if uncommented
print(array2.sum()) // 7
// print(set.sum()) // prints 7 or traps randomly between runs if uncommented

Maybe I shouldn't have used the word "correct", I meant something like this.

I think most people would expect the result of a method called sum() to produce the same result no matter the order of the elements, so I agree with what you said here:

(Although it's of course not possible. But we could perhaps say that mathematically named functions in Swift should make an effort to not surprise people.)