Swift 3.0 migration error: Type 'Element' constrained to non-protocol type 'IndexPath' Swift 3.0 migration error: Type 'Element' constrained to non-protocol type 'IndexPath' swift swift

Swift 3.0 migration error: Type 'Element' constrained to non-protocol type 'IndexPath'


You can use a specific type with a different syntax:

extension Array where Element == IndexPath {

As opposed to the more historic syntax for protocols:

extension Array where Element: Indexable {

Previously you could / had to shuffle around problems by creating a protocol, something like:

protocol Indexable {    var row: Int { get }    var section: Int { get }}extension IndexPath: Indexable {}extension Array where Element: Indexable {    ...