c++ - How to check for equals? (0 == i) or (i == 0) -


okay, know following 2 lines equivalent -

  1. (0 == i)
  2. (i == 0)

also, first method encouraged in past because have allowed compiler give error message if accidentally used '=' instead of '=='.

my question - in today's generation of pretty slick ide's , intelligent compilers, still recommend first method?

in particular, question popped mind when saw following code -

if(dialogresult.ok == messagebox.show("message")) ...  

in opinion, never recommend above. second opinions?

i prefer second one, (i == 0), because feel more natural when reading it. ask people, "are 21 or older?", not, "is 21 less or equal age?"


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -