Wed 29 Nov 2006
if they’re the same thing do nothing, if they’re different things do something
Posted by Steve Knight under java, ruby
No Comments
So I’m inspired by this post at the Daily WTF. The problem happens quite a lot in Java and I’m sure I’ve come across it myself at least once.
The central issue is, how do you safely (i.e. no NPE!) and cleanly compare two values where both could be null?
It’s only a small challenge, I grant you, but the code sample they have at WTF will return false if two Boolean’s have the same value, including nulls. (more…)