Note: This also applies for Swift 3.0
When I attempt to use the reduce
function, I get an error saying:
reduce is unavailable: call the 'reduce()' method on the sequence
I already figured out how to do this with the enumerate()
function but I cannot seem to solve this issue. Here is the line of code returning the error:
var hashValue: Int {
return reduce(blocks, 0) { $0.hashValue ^ $1.hashValue }
}
You fix this the same way that you fixed your problem with
enumerate()
. In Swift 2, reduce has been removed as a global function and has been added as an instance method on all objects that conform to theSequenceType
protocol via a protocol extension. Usage is as follows.