• 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
Inside or outside an if statement - what's the difference?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Inside or outside an if statement - what's the difference?
      • From: James Bucanek <email@hidden>
  • Prev by Date: Re: NEWBIE - production version - zerolink
  • Next by Date: Re: NSTextView typing speed - slowdown at top?
  • Previous by thread: Re: bindings: communicate changes of object to a collection
  • Next by thread: Re: Inside or outside an if statement - what's the difference?
  • Index(es):
    • Date
    • Thread