Skip to content
RED SAG Skills
mediumStudy question · answer published in Swift interview questions, so no pointsswiftproperties

Reacting when a value changes

What does this print after cart.count = 3?

struct Cart {
    var count = 0 {
        didSet { print("Changed from \(oldValue) to \(count)") }
    }
}
var cart = Cart()
cart.count = 3
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions