I'm having trouble working out how to access an actor from a filter closure. Take this example code:
import Foundation
actor MyActor {
var contents: [String]
init() {
self.contents = []
}
}
let myActor = MyActor()
let list: [String] = []
Task {
list.filter { item in myActor.contents.contains { $0 == item } }
}
I get the syntax error: Actor-isolated property 'contents' can not be referenced from a non-isolated context
. Which makes sense, but I just cannot work out how to provide the correct syntax.