Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I prefer not writing for loops unless I really need to. If I need to, I'll use foreach or for ... in syntax, depending on the language.
I make an effort to not write the classic for-loop.
Use map, filter, reduce or any more abstract sequence helper function. It's far more readable and really describes your problem.
Removing side effects is a nice bonus. -
Mitiko62067y@FilipeRamalho Well, I cannot use the same variable again later on code. (I guess places means elsewhere in the code)
@k0pernikus If this was js, I would consider. It is my fault for not specifying the language, though. C#
@Agred I didn't see that one comming. But this way, I never really use index 0. -
@Mitiko There are ways to achieve that if you only want it hard enough ;) (or use a library): https://stackoverflow.com/q/40075/...
What do you prefer:
for(int i = 0; i <= maxValue; i++)
Or
for(int i = 0; i < maxValue + 1; i++)
question