> As stated before it supposed to be per case initialization. You cannot
> really have this analogy with other types as they have type and
> instance while enums have type, case and instance.

No. If structs have just type and instance, then so do enums.

Cases in enums are analogous to stored properties in structs: they are a means 
of organizing and representing concrete storage. They are not first-class 
entities in the way that types and instances are. Much mischief comes from 
thinking of cases as pseudo-types, or as some sort of peer to a type.

> But consider this:
> 
> struct Struct {
>    static let bezierPath: UIBezierPath // shared
> 
>    static func initialize() {
>        bezierPath = UIBezierPath()
>    }
> }

Yes, because there's a `static` keyword on that declaration. That marks it as 
something different from an ordinary `let`. Similarly, part of the idea of my 
use of accessors is that the `accessor` keyword marks it as something different 
from an ordinary `var`.

(Also, you shouldn't use `initialize()` in Swift; you should set the variable 
directly. Also also, I'm pretty sure that wouldn't work at all, because 
`initialize()` is a normal method, not an initializer, and `bezierPath` is a 
constant.)

-- 
Brent Royal-Gordon
Architechies

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to