Cannot invoke 'filter' with an argument list of type '((_) -> _)'

前端 未结 2 1373
挽巷
挽巷 2020-12-20 12:15

Sounds ridiculous, but I\'m unable to fix this piece of code:

self.runningScripts.filter({ $0 != scriptRunner })

No matter how I write the

2条回答
  •  离开以前
    2020-12-20 13:02

    You can get that error if you didn't make ScriptRunner conform to Equatable:

    class ScriptRunner : Equatable {
        // the rest of your implementation here
    }
    
    func ==(lhs: ScriptRunner, rhs: ScriptRunner) -> Bool {
        return ... // change this to whatever test that satisfies that lhs and rhs are equal
    }
    

提交回复
热议问题