Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I always find if I need to loop a list there is a good chance the index can help

You may always find this, but lots of people don't. I find myself doing lots of iteration that doesn't need the index.

and even if I don't need it it doesn't hurt to have one either

Yes it does, because you're adding extra code to compute the index to every iteration, whether it's needed or not. It's not a good idea to encumber such a basic language construct with any extra baggage; that's why the extra baggage is in "enumerate", so you only get it if you actually need it.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: