• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: Avoiding == and = mixup in if statements
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Avoiding == and = mixup in if statements


  • Subject: RE: Avoiding == and = mixup in if statements
  • From: Lance Drake <email@hidden>
  • Date: Sat, 22 May 2004 02:33:36 -0600

One way to avoid this problem is to put the CONSTANT in the lvalue position. The compiler will balk about your attempt to set it.

Plus, it forces a read of the variable - as opposed to relying what's in some register if you have the variable in the rvalue position. All such tests in my code are constructed as shown. If I goof and only type one equal sign, I get an error.

if(nil == somevar) { dependentaction(); }

Lance Drake
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Variable argument lists
  • Next by Date: objectAtIndex quandry
  • Previous by thread: Re: Avoiding == and = mixup in if statements
  • Next by thread: Re: Avoiding == and = mixup in if statements
  • Index(es):
    • Date
    • Thread