• 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: Good idea/bad idea?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Good idea/bad idea?


  • Subject: Re: Good idea/bad idea?
  • From: Sean McBride <email@hidden>
  • Date: Fri, 25 Apr 2014 10:22:11 -0400
  • Organization: Rogue Research Inc.

On Thu, 24 Apr 2014 14:45:58 -0700, Quincey Morris said:

>> I still don't see how
>>
>> foo = [@"Something" fallbackIfNil:foo];
>>
>> has any advantage over
>>
>> foo = foo ?: @"Something";
>
>I don’t see how the latter has any advantage over your earlier
>suggestion [more or less]:
>
>	if (!foo)
>		foo = @“Something”;
>
>Admittedly, it takes two lines instead of one. OTOH, as I said in
>another recent thread, it seems to me that for a *reader* of the code,
>the latter form is far more accessible than code with the “?…:”
>operator, which tends to force the reader to figure out if the code is
>correct or not.

The 'if form' is arguably better for testing too.  Many code coverage tools are line-based, and with this form it's easier to see if your test cases cover going in the branch and not.

Cheers,

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Good idea/bad idea?
      • From: Andy Lee <email@hidden>
References: 
 >Good idea/bad idea? (From: Alex Zavatone <email@hidden>)
 >Re: Good idea/bad idea? (From: Luther Baker <email@hidden>)
 >Re: Good idea/bad idea? (From: Lee Ann Rucker <email@hidden>)
 >Re: Good idea/bad idea? (From: Alex Zavatone <email@hidden>)
 >Re: Good idea/bad idea? (From: Andy Lee <email@hidden>)
 >Re: Good idea/bad idea? (From: Quincey Morris <email@hidden>)

  • Prev by Date: What is "CoreData: Error: Unable to dynamically link Librarian.framework"
  • Next by Date: Re: Good idea/bad idea?
  • Previous by thread: Re: Good idea/bad idea?
  • Next by thread: Re: Good idea/bad idea?
  • Index(es):
    • Date
    • Thread