I want to try to write a default init in a protocol extension, so I did this:
protocol P {
var data: [AnyHashable: Any] { get }
init(_ s: String)
}
extension P {
init(_ s: String) {
self.data = ["s": s]
}
}
But I'm getting this error:
'let' property 'data' may not be initialized directly; use "self.init(...)" or "self = ..." instead
I have no idea what it means. Thanks for your help!