Last active
August 30, 2020 00:54
-
-
Save laevandus/0601815d70ba684d49195eb7b09d5692 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct TemperatureLimits { | |
var low: Int = 5 { | |
didSet { | |
let high = max(self.high, low + 10) | |
guard self.high != high else { return } | |
self.high = high | |
} | |
} | |
var high: Int = 30 { | |
didSet { | |
let low = min(self.low, high - 10) | |
guard self.low != low else { return } | |
self.low = low | |
} | |
} | |
var lowNumber: NSNumber { | |
get { NSNumber(value: low) } | |
set { low = newValue.intValue } | |
} | |
var highNumber: NSNumber { | |
get { NSNumber(value: high) } | |
set { high = newValue.intValue } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment