I'm following Google's learning path for kotlin, and have arrived at classes and objects. The final challenge is to, on your own, continue building out the smart home system you see in the text snippet. I'm currently trying to figure out how to make sure any commands to devices only fire if the devices have an "on" status.
My first thought was to build around "Only execute these functions if..." logic. But if there's any strategies to implement this behavior without lots of redundancy, I don't think I've learned them yet.
So my next thought was "Only allow these VALUES to be updated if..." This is much more consistent with the little I've learned about delegates.
So I thought, in the delegate I've already built that makes sure values are in an acceptable range, I'll just add an "&& isOn" check to the setter. But this doesn't work either because my delegate only gets the device's status once and that's before it's assigned a value.
Gemini tells me I need to update ReadWriteProperty to a type of SmartDevice so that I can reference the caller's device status on every fire with thisRef, but that's absurd right? It totally breaks the interface.
So what other options do I have? Is there even a way with the knowledge I have as demonstrated here to make the delegate check the value of the calller's device status on every set?