HomeGenie Forum

General Category => Troubleshooting and Support => Topic started by: bkenobi on February 19, 2014, 03:48:22 PM

Title: return True/False explanation
Post by: bkenobi on February 19, 2014, 03:48:22 PM
Can you explain why sometimes the following code returns true and others false?  I'm not sure how the statement is used in this scenario.

Code: [Select]
var smart_devices = Modules.WithFeature(SMART_LIGHT_ENABLE);
smart_devices.Each((mod)=>
{
  if (module.Instance.Name=="Entry Light"))
  {
    //code to do stuff
    ...
  }
     
  return true;
});
Title: Re: return True/False explanation
Post by: Gene on February 19, 2014, 04:00:29 PM
If you return true, the iteration will break. If you return false, it will continue iterating to the next element in the selection.
I made a correction the the api docs so it should be more clear:

http://www.homegenie.it/docs_old/api/modules.html#each

g.
Title: Re: return True/False explanation
Post by: bkenobi on February 19, 2014, 04:46:36 PM
That makes sense.  Thanks!