I can’t thank you enough for that.
I totally missed that you can impart behavior to all the types that are part of
a generic type by doing a protocol on the generic type itself (i.e. extension
Set: MyEncodable).
This approach is really what I wanted because it lets an outside user create
their own type and then make it be serializable without *me* (as the author of
this facility) knowing they’ve done that.
——————————————
(after some implementation)
extension Set: MyEncodable {
func encoded() -> Any {
return self.map { $0 }
}
func decoded(_ input: Any) -> Set {
if let listVal = input as? [Set.Element] {
return Set(listVal)
}
return self
}
}
C++ blows. Swift rocks.
Thank you again.
_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users