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

I agree of course but I'd argue that an array lookup would be more readable and more maintainable than this `if` soup in the `getCountry` example code. One added benefit for instance is that the language will never allow you to declare two values for the same index, whereas you could very easily mess up a copy/paste and forget to update the condition.

More generally I don't think we should consider that readability and efficiency are at opposing ends of the same axis. With a bit of care and good tools it's often possible to get the best of both worlds, or close enough.



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

Search: