4 ms·
I think it hurts readability. But sometimes it is nice to skip a null check. i.e. instead of: if (a != null && a.equals(b)) You can often do: if (b.equals(
by chengas123 17y ago
I think it hurts readability. But sometimes it is nice to skip a null check. i.e. instead of:
if (a != null && a.equals(b))
You can often do:
if (b.equals(a))
- pyre 17y agoThose 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.