• 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: == nil vs. isEqual:nil
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: == nil vs. isEqual:nil


  • Subject: Re: == nil vs. isEqual:nil
  • From: Jim Correia <email@hidden>
  • Date: Thu, 16 Aug 2001 14:49:38 -0400

At 12:49 PM -0500 8/16/01, Jonathan Hendry wrote:

It's a little better if you can get into the habit of doing

if (nil == anObject)

I agree that this is an excellent habit to get into (and it can be hard because as you say the code to yourself as you are writing it, it sometimes just sounds wrong).

That way, if you accidentally do "if (nil = anObject)" you'll
get a compiler warning.

On the other hand, if you accidentally type "if (anObject = nil)" then
you get no compiler warning and anObject gets set to nil.

Most compilers have a warning for possible unintended assignments.

In gcc, it is -Wparentheses. Worth turning on, even if you write code like the first example but sometimes inherit other people's code.

Jim


References: 
 >Re: == nil vs. isEqual:nil (From: Jonathan Hendry <email@hidden>)

  • Prev by Date: Re: Building and installing JDOM
  • Next by Date: Re: Is encapsulation deprecated in ObjC?
  • Previous by thread: Re: == nil vs. isEqual:nil
  • Next by thread: Re: == nil vs. isEqual:nil
  • Index(es):
    • Date
    • Thread