I have created a protocol:
public protocol MyProtocol {
func doTask()
}
Then, I have an array for elements with MyProtocol type:
var taskList: [MyProtocol] = []
Callers can add elements to taskList, eventually, I got an non-empty taskList.
Now, I need to have a function that could remove an element from taskList, this is what I tried:
func removeTask(task: MyProtocol) {
// Compiler error: Binary operator '!==' cannot be applied to two 'MyProtocol'
taskList = taskList.filter{$0 !== task}
}
But I get compiler error: Binary operator '!==' cannot be applied to two 'MyProtocol'
How to get rid of this error?
=== UPDATE ===
Thanks @holex, after changed MyProtocol to be class-only, it works fine. But now I wonder if I need MyProtocol to be not class-only, what would be the solution then?