You are reading a single comment by @stephenPspackman and its replies.
Click here to read the full conversation.
-
search: for (…) for (…) if(…) break search; // found it!
One could of course throw an exception, use “continue” variables, or any of a number of other solutions; they're all to varying degrees confusing or inefficient
what about making it a function named 'search' and
return
found item from it? if it does something and has a name isn't function that idiom?
This may be a flaw in the Espruino documentation, then—it says there that the reason labels are not implemented is that they are bad practice, not because of the implementation strategy.
My particular use case is of this form:
search: for (…) for (…) if(…) break search; // found it!
One could of course throw an exception, use “continue” variables, or any of a number of other solutions; they're all to varying degrees confusing or inefficient, and I just wondered what the received idiom is.