[swift-evolution] [Proposal] Enums with static stored properties for each case

Brent Royal-Gordon brent at architechies.com
Wed Jun 1 16:18:25 CDT 2016


> UIBezierPath is shared for all instances of the enum case. So stored
> properties are stored per case, not per instance (you have associated
> values for per instance values).
> 
>> that isn't really what this syntax suggests is happening
> 
> Please explain what makes you think that way.

Because you wrote `let bezierPath = UIBezierPath()` in the middle of a type definition, and in all other types, you would get a new bezier path for each instance.

	struct Struct {
		let bezierPath = UIBezierPath()		// per instance
	}
	class Class {
		let bezierPath = UIBezierPath()		// per instance
	}
	func function() {
		let bezierPath = UIBezierPath()		// per call
	}
	enum Enum {
		case aCase {
			let bezierPath = UIBezierPath()	// shared?!?!
		}
	}

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list