听起来很可笑,但我无法修复这段代码:
self.runningScripts.filter({ $0 != scriptRunner })
无论我如何写封闭,我总是得到这个错误:
Cannot invoke ‘filter’ with an argument list of type ‘
((_) -> _)
‘
runningScripts定义如下:
var runningScripts = [ScriptRunner]()
ScriptRunner是一个Swift类(不继承NSObject)
我在许多其他地方使用几乎相同的地方没有问题.有什么建议么?
如果没有使ScriptRunner符合Equatable,则可以得到该错误:
原文链接:https://www.f2er.com/swift/319626.htmlclass 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 }