Lazy var initialization error "Cannot use mutating getter on immutable value"
Advertisements I tried two ways of initializing a lazy var, one works, the other gets a compiler error. OK: var maxDiscount = MaxDiscount(); maxDiscount.maxDiscountPercent ERROR: MaxDiscount().maxDiscountPercent If maxDiscountPercent was a stored property rather than a lazy var both usages would work. Simplified example: struct MaxDiscount { lazy var maxDiscountPercent: Int = { print("Lazy var maxDiscountPercent… Read More Lazy var initialization error "Cannot use mutating getter on immutable value"