I’d like to unterstand the difference between sending a command down like
sendCommand(gLights, OFF)
and doing it like this
gLights?.members.forEach[item|
sendCommand(item, OFF)
]
Is there any difference at all?
I’d like to unterstand the difference between sending a command down like
sendCommand(gLights, OFF)
and doing it like this
gLights?.members.forEach[item|
sendCommand(item, OFF)
]
Is there any difference at all?
Functionally they are equivalent.
The big difference is with the latter gives you the opportunity to add more logic, for example, only send OFF if the item is ON:
gLights?.members.forEach[item|
if(item.state != OFF) item.sendCommand(OFF)
]
NOTE: It is best to use the sendCommand method on the Item if you have a reference to the Item. The sendCommand action sometimes doesn’t handle different types of states very well.
Could you please elaborate