| ▲ | AlotOfReading 6 hours ago | ||||||||||||||||
I really don't see what's supposedly awful about that loop, but if you want to count down to x instead of 0 you just do: | |||||||||||||||||
| ▲ | dataflow 6 hours ago | parent | next [-] | ||||||||||||||||
> I really don't see what's supposedly awful about that loop The stopping condition is incredibly confusing and non-obvious. Misleading at first glance, in fact. The whole thing is so unidiomatic that I don't think I've even seen it once in my life. It's a better contender for an underhanded C++ code contest than production code. > but if you want to count down to x instead of 0 you just do i >= x No you can't. That fails if x == 0. Which perfectly illustrates why using unsigned everywhere isn't so great. And I say this as someone who likes unsigned types and uses them more than average! | |||||||||||||||||
| |||||||||||||||||
| ▲ | StellarScience 6 hours ago | parent | prev [-] | ||||||||||||||||
> I really don't see what's supposedly awful about that loop Exactly! That's precisely the problem with it. (Hint: think about your code when size = 0.) | |||||||||||||||||
| |||||||||||||||||