Inside or outside an if statement - what's the difference?
Inside or outside an if statement - what's the difference?
- Subject: Inside or outside an if statement - what's the difference?
- From: Ian Jackson <email@hidden>
- Date: Thu, 29 Sep 2005 22:27:39 +1200
Hi everyone,
I have a little bit of code that looks like this:
- (NSBezierPath *)addSegmentToPath:(NSBezierPath *)aPath {
if (meetConditions) {
aPath = [self addParticularSegmentToPath:aPath];
}
return aPath;
}
- (NSBezierPath *)addParticularSegmentToPath:(NSBezierPath *)thePath {
[thePath lineToPoint:[self somePoint]];
return thePath;
}
Which doesn't do what I expect it to. Changing the first method to
this fixes it:
- (NSBezierPath *)addSegmentToPath:(NSBezierPath *)aPath {
aPath = [self addParticularSegmentToPath:aPath];
return aPath;
}
i.e. taking the aPath = [self addParticularSegmentToPath:aPath];
portion out of the if statement makes it work. It works, but it
doesn't help, since in my actual app, I expect to be able to choose
addParticularSegmentToPath out of a number of similar methods,
depending on things elsewhere. It seems to suggest there's something
I'm totally not getting about what goes on with if statements.
Any ideas?
Ian.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden