So I had this totally retarded conversation today with some guy about whether for loops are better or while loops.
Now I'm here to spread retardation to you, because I have nothing better to do right now (ok, that's a lie I have loads of better stuff I could be doing but whatever).
EDIT: Now color coded and shit to increase your interest in voting (lol).... yeah.
Clicked the
RED one because its mah favorite color

i use for loops much more than while ones, because they're more verbose and make my code easier to understand.
the incrementing element, breaking condition and iterator is all there.
i only use while loops for stuff that isn't an integer increment, like:
Code:
while(!pIfstream.eof())
{
cout << var << endl;
}
|
I've only been programming for a year and a half, so my use of looping so far i would say is rather limited compared to more seasoned programmers.
It really depends on your situation, though I use for loops more.
I'm pretty sure they just fit different circumstances. One isn't really better than the other.
In bash, there are 3 kinds of loops: for, while, and until.
trademark91 Wrote: [ -> ]I'm pretty sure they just fit different circumstances. One isn't really better than the other.
Yeah, which is why I mentioned the convo was pretty retarded. But a lot of cases you an use both and so it really just comes down to personal preference.
trademark91 Wrote: [ -> ]In bash, there are 3 kinds of loops: for, while, and until.
Yeah there are other types of loops like a do while loop and stuff, but for and while are the main types of loops pretty much every programming language has.
I only use while for a timer or counter.
I use For way more often.
So in the spirit of the poll, For Loops are the greatest evar!1!
ZiNgA BuRgA Wrote: [ -> ]I prefer foreach loops.
there's always one :]
I'm seeing a disgusting amount of votes for silly For loops.
I think For loops are restricted compared to While loops. On the other hand, it's a lot easier to derp up a while loop by forgetting to increase whatever it is that controls the loop.
While Loop master race.