Re: == nil vs. isEqual:nil
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.