6 ms·
This is completely another level of "issues" than other problems in this thread. During code review I'd only mention it as a nit. The longer form is correct and
by ickyforce 4y ago
This is completely another level of "issues" than other problems in this thread. During code review I'd only mention it as a nit. The longer form is correct and the only downside is that's a bit longer. It doesn't mess up code modularity or affect maintainability in a noticeable way.
Well, assuming that the language doesn't have any quirks in this area - e.g. in Java your statements aren't equivalent for a Boolean x.
- kaba0 4y agoNitpick (as in general you are right regarding java as well): I’m fairly sure they are the same for java in this instance. Both will convert Boolean to boolean, throwing an NPE if it was a null.
- ickyforce 4y agoHa, that's true, thanks! I guess my Java-fu is weak these days :)
- wizofaus 4y agoThey're not equivalent in many languages (JS, C++/swift with operator overloads, if x is nullable etc. etc.).