Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!emory!hubcap!ncrcae!ncr-sd!se-sd!rns From: rns@se-sd.SanDiego.NCR.COM (Rick Schubert) Newsgroups: comp.lang.c Subject: Re: Assignment in test: OK? Message-ID: <3836@se-sd.SanDiego.NCR.COM> Date: 10 Sep 90 19:38:04 GMT References: <1990Sep5.185451.25532@DRD.Com> <1990Sep7.042759.3804@ux1.cso.uiuc.edu> Organization: NCR Corporation, Systems Engineering - San Diego Lines: 19 In <1990Sep7.042759.3804@ux1.cso.uiuc.edu> gordon@osiris.cso.uiuc.edu (John Gordon) writes: > One way to avoid the =/== pitfall is to write your code like this: > if(7 == x) rather than if(x == 7). > If you write it the first way, and accidentally write = instead of ==, > you will be trying to assign a value to a constant (!!) and will get > an error. I have seen this suggestion in this newsgroup quite a few times in the past and I always wonder: If you remember to put the constant on the left, won't you also remember to use `==' rather than `='? [Personally, I think `if(7 == x) is ugly.] -- Rick Schubert (rns@se-sd.sandiego.NCR.COM)