I am trying to understand Computed Properties mostly I have understood the concept but one output is confusing me
struct SomePrices {
var eighth: Double
var quarter: Double
var half: Double
var zip: Double {
get {
return half * 2 - 20
}
set {
eighth = newValue / 8 + 15
quarter = newValue / 4 + 10
half = newValue / 2 + 5
}
}
}
var gdp = SomePrices(eighth: 37.0, quarter: 73.0, half: 123.0)
gdp.eighth // 37
gdp.quarter // 73
gdp.half // 123
gdp.zip // 226
gdp.zip = 300
gdp.eighth // 52.5
gdp.quarter // 85
gdp.half // 155
gdp.zip // 290
Been trying to understand how did I get 290 when gdp.zip = 300