I use object != null
a lot to avoid NullPointerException.
Is there a good alternative to this?
For example I often use:
Ultimately, the only way to completely solve this problem is by using a different programming language:
nil
, and absolutely nothing will happen. This makes most null checks unnecessary, but it can make errors much harder to diagnose.