Jump to content

Talk:While loop

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Codehead1 (talk | contribs) at 19:32, 1 June 2009 (Perl example: new section). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The example given on this page is badly chosen, when the number of iterations is known a For loop is the better choice than a while loop. It is the main difference between a for and a while loop, for a while loop you do not need to know the number of iterations up-front, that is, a while loop is more powerful and the example should illustrate that. Alas, I am not knowledgeable in all ten languages presented on the page and can thus not change the example.

Perl example

Regarding "Very similar to C and C++, but the while loop could also have been written on one line:":

Why is this example used? Apparently to show off Perl's compactness compared to C and C++, except that C and C++ can do it in one line also, just as compact. That part should be deleted.