> The suggested solution based on 'accessor' - will create assotiated
> properties each time the enum instace created, for each instance of enum type.
No; property accessors would be either computed or constant (so that all
instances of a given case can share storage). This is much the way they would
behave if they were included in behaviors.
You could write a property accessor with a setter, but it would have to be
computed, and manipulate `self`'s cases and associated values:
enum Optional<T> {
accessor var unwrapped: T { get set }
case none {
unwrapped {
get { fatalError("No value") }
set { self = .some(newValue) }
}
}
case some (_ value: T) {
unwrapped {
get { return value }
set { self = .some(newValue) }
}
}
}
--
Brent Royal-Gordon
Architechies
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution