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

Those are not strictly equivalent, in that b.equals(a) could evaluate to true when both are null which would fail in the first form you gave.

I'm sort of reaching here, because I don't know off-hand which language you are using, but I would assume that NULL.equals() would throw an exception. That exception would not be thrown/need to be caught in the first example.



Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: