On Jul 22, 2008, at 11:54 PM, Steve Cronin wrote:

I find if I have a method which returns an NSString for example, that often, in the interior of that method I will use an NSMutableString to construct the string I intend to return. My question concerns the actual final return statement.

Is there ANY reason to choose A over B?

A) return [NSString stringWithString:myWorkingMutableString];

B) return myWorkingMutableString;

It just kinda sticks in my craw me that I 'promised' an NSString and using (B) I don't return one. Yeah I do understand inheritance and that a mutable entity isKindOfClass of the base class I looking for reasons like edge cases, compiler optimization, error trapping, portability, etc.. Is there ANY benefit to the costs associated with the explicit declaration of (A)?

I think there was a pretty good discussion of this issue in this thread: http://lists.apple.com/archives/Cocoa-dev/2008/Jun/msg00188.html

Cheers,
Ken
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to