[swift-evolution] [Proposal] Make `didSet` also available for `let` property, or something new such as `didInit`

Michel Fortin michel.fortin at michelf.ca
Wed Dec 23 12:39:56 CST 2015

Le 23 déc. 2015 à 11:07, Félix Cloutier via swift-evolution <swift-evolution at swift.org> a écrit :

> willSet and didSet are currently not even called from the init method.

And they can't, because in those two blocks you have access to the old value as well as the new value. How would that work when you're setting the initial value?

	var value: Int {
		willSet { print("willSet \(value) -> \(newValue)") }
		didSet { print("didSet \(oldValue) -> \(value)") }

Michel Fortin

More information about the swift-evolution mailing list