Joseph Toronto Joseph Toronto - 3 months ago 42
Swift Question

Swift 3.0 array "contains" argument compiler error

Here is the statement that's causing trouble. This worked perfectly in Swift 2.2 but is not working in 3.0 and Xcode 8.

keys = keys
.filter { !indexesToRemove.contains($0.index) }
.map { $0.element }

Right at
xCode is throwing a compiler error:

Value of tuple type '(offset: Int, element: Any)' has no member 'index'

As far as I know $0 represents objects in the
array. What tuple is it talking about?


index has been changed to offset in Swift 3 (don't ask me why):

keys = keys
    .filter { !indexesToRemove.contains($0.offset) }
    .map { $0.element }