• 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: logical (! object) vs (object != nil)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: logical (! object) vs (object != nil)


  • Subject: Re: logical (! object) vs (object != nil)
  • From: Marco Scheurer <email@hidden>
  • Date: Tue, 26 Aug 2003 01:33:17 +0200

On Tuesday, August 26, 2003, at 12:46 AM, Alastair J.Houghton wrote:

On Monday, August 25, 2003, at 07:39 pm, Anders Totland wrote:

I have a (C noob) question. Are the two statements (! object) and (object != nil) the same statement, with identical meaning?

They are expressions and not statements, but yes, they are identical (since nil is zero).

I know it's a typo but as written, they are the opposite of each other.

In practice, (!object) and (object == nil) are the same, and which one you use is a matter of style and preferences.

See "Is the abbreviated pointer comparison 'if(p)' to test for non-null pointers valid? What if the internal representation for null pointers is nonzero?" at

http://www.eskimo.com/~scs/C-faq/q5.3.html

Marco Scheurer
Sen:te, Lausanne, Switzerland http://www.sente.ch
_______________________________________________
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.

  • Follow-Ups:
    • Re: logical (! object) vs (object != nil)
      • From: "Alastair J.Houghton" <email@hidden>
References: 
 >Re: logical (! object) vs (object != nil) (From: "Alastair J.Houghton" <email@hidden>)

  • Prev by Date: Re:(new problem) Selecting item in NSTableView when right-clicked on...
  • Next by Date: Re: Help me, which book I should buy to learn Cocoa??
  • Previous by thread: Re: logical (! object) vs (object != nil)
  • Next by thread: Re: logical (! object) vs (object != nil)
  • Index(es):
    • Date
    • Thread