• 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: Jonathan Hendry <email@hidden>
  • Date: Thu, 16 Aug 2001 12:49:13 -0500

On Wednesday, August 15, 2001, at 04:32 , Mike Beam wrote:

Hello All,

Thanks for all the replies. A couple of people pointed out that isEqual:nil
will not work since nil responds to most messages with "0", which would make
isEqual return NO even if the receiver were indeed nil. I din't think even
think of that before submitting my question. I think I'm a fan of

if ( anObject == nil )

As opposed to if(!anObject). I think it's more readable and explicit as to
what is being tested.

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

if (nil == anObject)

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.


  • Follow-Ups:
    • Re: == nil vs. isEqual:nil
      • From: Luc Heinrich <email@hidden>
    • Re: == nil vs. isEqual:nil
      • From: Jim Correia <email@hidden>
References: 
 >Re: == nil vs. isEqual:nil (From: Mike Beam <email@hidden>)

  • Prev by Date: How to port a Unicode Unix app?
  • Next by Date: RE: Online C++ resources?
  • Previous by thread: Re: == nil vs. isEqual:nil
  • Next by thread: Re: == nil vs. isEqual:nil
  • Index(es):
    • Date
    • Thread