While I use the first for the reason described by fvasco (you’d have to use varable!! in many cases), I don’t find it to be really clear for those new to the language. To address, I created a function whenNotNull()
, which I can use as:
whenNotNull(variable) { }
This seems slightly more self documenting and understable from my perspective.