user523234 user523234 - 4 years ago 109
Swift Question

Swift 3: Binary operator '!==' cannot be applied to two 'indexPath' operands

The error came from this. Which was woring fine under Swift 2.3

selectedIndexPaths = selectedIndexPaths.filter() { $0 !== indexPath}


var selectedIndexPaths: [IndexPath] = []

Any suggestion?

Answer Source

Simply use !=.

It doesn't make sense to compare indices as references.

IndexPath is a struct (compared to NSIndexPath that is a class type), therefore it's not possible to compare references. However it never made really sense. Just compare them for equality.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download