Reputation: 7413
In Swift 2.2 I created a section index of my data with this code.
func createSectionIndices(_ participants: List<Participant>){
let array = participants.sorted(by: {$0.lastName.uppercased() < $1.lastName.uppercased()})
sections = array
.map({String($0.lastName.uppercased().characters.first!)})
.enumerated()
.filter({ $0 == 0 || !participants[$0 - 1].lastName.uppercased.hasPrefix($1) })
.map({ (start,letter) in return
(
index: start,
length: participants.filter({$0.lastName.uppercased.hasPrefix(letter)}).count,
title: letter
)
})
}
Now with Swift 3.0 "Ambiguous reference to member '-'" in the line with the filter. .filter({ $0 == 0 || !participants[$0 - 1].lastName.uppercased.hasPrefix($1) })
How can this be fixed in Swift 3.0? Why is it ambiguous?
Upvotes: 0
Views: 1132
Reputation: 285150
The error is a bit misleading, uppercased
has been changed to uppercased()
Upvotes: 4