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

I would agree with you.

The only reason I can see for the advice is that the first line does not handle that foo (#) might be other than a string - for example if foo was [1,2,3] you just got [1,2,3,'ooo']. the second line would barf on that. But if that was the case it is waaaay more readable to explicitly test for that

so yeah, generally not great advice

(#) Holy moly how many times will autocorrect change foo to too!!! stop it!



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

Search: