Hacker News new | past | comments | ask | show | jobs | submit login

sounds like a great way to introduce bugs



How so?


because when you misscalculate the index, then it will not crash, but use the wrong one

I'm getting this right?


I don't understand why that would be more error prone than using list[list.length-1]. It's just list[-1].


imagine if you used list[index] where index would be calculated

if you misscalculated something and went on negative, then you'd have big exception/error, but when negative indices are viable, then the code will work fine




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

Search: