I think I don't understand how protocol extensions are supposed to work.
I tried this:
protocol P {
var h: [String: Any] { set get }
}
extension P {
var h: [String: Any] {
get {
return [:]
}
set {}
}
}
struct S: P {
init() {
self.h = ["o": "o"]
}
}
My goal is that S has the properties of P and doesn't need to re-declare it in the struct definition.
However, when I create let s = S(), s.h always equals [:] and not ["o":"o"].
Of course, this is because my setter is empty, but I don't know how to do what I want to achieve here.
Thanks for your help.