Missing argument label 'where' in call

I am calling the array's 'contains' method, and I keep getting this very frustrating error. I've done the legwork, adding the label 'where' calls a completely different method. did some preliminary searches and the online community is addressing Other issues unrelated to my issue, because I am comparing apples to apples. here's the code:

var children : [baseArrObj] = []{
        didSet{
            let rem = children.filter({ oldValue.contains($0) == false })
            let add = oldValue.filter({ children.contains($0) == false })
            ref!.baseUpdated(rem: rem, add: add)
        }
    }


I routinely use code just like this to identify the added and removed items in an array. It's only giving me a headache now, in a playground.


this is the error I get on both lines 3 and 4:

Missing argument label 'where:' in call


if I add that label, I get a completely new set of error as the new method referenced : contains(where:) throws. It's completely innappropriate for my use, and should be entirely uneccesary.


what is really going on here? the types referenced are exactly the same ie: comparable. I am in no way coercing types, and frankly... all of the code i have just written is a sidebar to test a complicated pattern I'm adding to a larger project. I USE MUCH more elaborate code that relies on the "contains()" method with no issues whatsoever.

That's not the answer, but just for my understanding.


Haven't you permuted rem and add ?

            let rem = children.filter({ oldValue.contains($0) == false })
            let add = oldValue.filter({ children.contains($0) == false })

should be

            let add = children.filter({ oldValue.contains($0) == false })
            let rem = oldValue.filter({ children.contains($0) == false })



I tried in playgroung with [Int] and do not get the message.

But I get it with objects as

class Shape {   
    var numberOfSides: Int
   
    init(numberOfSides: Int) {
        self.numberOfSides = numberOfSides
    }
   
}



Making Shape Equatable removes the error


class Shape: Equatable {
    static func == (lhs: Shape, rhs: Shape) -> Bool {
        return lhs.numberOfSides == rhs.numberOfSides
    }
   
    var numberOfSides: Int
   
    init(numberOfSides: Int) {
        self.numberOfSides = numberOfSides
    }
   
}

Claude31 is right, you permuted the removed and the adds, the following code works ok.


import UIKit

class Reference{
    var removed : [String] = []
    var added : [String] = []
    
    func baseUpdated(added: [String], removed: [String]){
        self.removed.append(contentsOf: removed)
        self.added.append(contentsOf: added)
    }
}

class ViewController: UIViewController {

    var baseArrObj : [String] = ["A", "B", "C", "D", "E", "F"]{
        didSet{
            let added =  baseArrObj.filter({ oldValue.contains($0) == false })
            let removed = oldValue.filter({ baseArrObj.contains($0) == false })
            reference.baseUpdated(added: added, removed: removed)
        }
    }
    
    let reference = Reference()

    override func viewDidLoad() {
        super.viewDidLoad()
        baseArrObj.append("G")
        baseArrObj.remove(at: 0)
        print("baseArrObj: ", baseArrObj)                    // prints: ["B", "C", "D", "E", "F", "G"]
        print("reference.added: ", reference.added)          // prints: reference.added:  ["G"]
        print("reference.removed: ", reference.removed)      // prints: reference.removed:  ["A"]
    }
}

Yes, but that's not in fact the real problem of eblu.


Your example works because objects are String, hence equatable.

But if baseArrObj are not equatable (which I suspect is the case for eblu), you get the error.

In fact, it is logic that object should be equatable.


However, the error message

Missing argument label 'where:' in call

is at least misleading !


See full example in the post above.

yes I may have swapped the add and rem values.

dyslexia is a real thing, and the only way to fight it is to test the code, which is impossible in it's current state.


I haven't tested the proposed solution yet, but it's a safe bet that since the class isn't equatable, that is the problem. It's likely something that NSObject adopts without any fanfaire?

You are right!.


The Type needs to conform Equatable protocol.

So, did Equatable solve your problem ?

Missing argument label 'where' in call
 
 
Q