• 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: meaning of if (self = [super init])
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: meaning of if (self = [super init])


  • Subject: Re: meaning of if (self = [super init])
  • From: "Alastair J.Houghton" <email@hidden>
  • Date: Wed, 25 Jun 2003 22:15:11 +0100

On Wednesday, June 25, 2003, at 04:23 pm, Ben Dougall wrote:

ifs don't just test for 0 or 1. they test 0, for negative, and any value greater than 0 for positive.

Strictly speaking, if expressions test for *non-zero* rather than "any value greater than zero"; that is, -5 and +5 are *both* true. The point is that only zero is false.

By the way, writing

if (self = [super init])

could cause a warning in GCC (depending on your compiler flags). GCC allows you to override the warning by writing an extra set of parentheses like this:

if ((self = [super init]))

(The point of the warning is to catch the case when you've accidentally written a single equals when you meant double equals.)

Kind regards,

Alastair.
_______________________________________________
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.

References: 
 >Re: meaning of if (self = [super init]) (From: Ben Dougall <email@hidden>)

  • Prev by Date: Re: OCUnit vs OBJCUnit
  • Next by Date: Re: colon in file names for maildir
  • Previous by thread: Re: meaning of if (self = [super init])
  • Next by thread: Possibly OT: Raw mouse data hook for switching of left/right mouse button
  • Index(es):
    • Date
    • Thread