Friday, 3 May 2013
"if(!fubar)" or "if(fubar == null)"?
I prefer 'if(!fubar)', it reads in my head at least more like english and should 'fubar' be templated '!furbar' makes sense with more basic types than comparing with null.
Perhaps most importantly, there is less changes of writing 'if(fubar = null)' by mistake. This of course is a good reason for writing instead 'if(null== fubar)'.
Indeed I wonder why 'if(fubar == null)' appears in my experience far more common than 'if(null== furbar)', perhaps because it reads more like the english language? If that is the case, why not write 'if(!fubar)'?
I sense I am going round in circles and will now end this senseless post ;)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment