--

Of course, but I also recognise that there can be more than one standard approach, depending on the circumstances.

I suspect you agree, because your article suggests two different standard approaches - using break, and using a function to detect the end condition - both of which are perfectly valid techniques in particular situations.

But simply using a while loop with a condition is also valid in some circumstances, for example if it is a very simple loop.

It is your assertion that a simple loop is "wrong" because it doesn't contain a break statement that I don't really agree with. If it is just a simple loop, there is no need to complicate it.

--

--

Martin McBride
Martin McBride

No responses yet