Re: meaning of if (self = [super init])
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.