• 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: More elegance than a long if/else
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: More elegance than a long if/else


  • Subject: Re: More elegance than a long if/else
  • From: Pascal Bourguignon <email@hidden>
  • Date: Sat, 11 Mar 2017 02:35:15 +0100

> On 10 Mar 2017, at 23:32, Quincey Morris <email@hidden> wrote:
>
> On Mar 10, 2017, at 08:24 , Bryan Vines <email@hidden> wrote:
>>
>> Would integer division work better than the modulus operator?
>
> It would certainly work better in the sense that division is the right operator and modulus is the wrong one!
>
> Regarding the original question, I would add that there’s a decent argument to be made that keeping a long series of cases is clearer in intent and methodology than a concise but somewhat obscure calculation.


Of course.

switch(x){
case 0: return y;
case 1: y++; return y;
case 2: y++; y++; return y;
case 3: y++; y++; y++ ; return y;
…
}

this is much clearer in intent than return x+y.  So much clearer…



--
__Pascal J. Bourguignon__



_______________________________________________

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: More elegance than a long if/else
      • From: Quincey Morris <email@hidden>
References: 
 >More elegance than a long if/else (From: "Eric E. Dolecki" <email@hidden>)
 >Re: More elegance than a long if/else (From: Jeff Kelley <email@hidden>)
 >Re: More elegance than a long if/else (From: "Eric E. Dolecki" <email@hidden>)
 >Re: More elegance than a long if/else (From: Jeff Kelley <email@hidden>)
 >Re: More elegance than a long if/else (From: Bryan Vines <email@hidden>)
 >Re: More elegance than a long if/else (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: More elegance than a long if/else
  • Next by Date: Re: More elegance than a long if/else
  • Previous by thread: Re: More elegance than a long if/else
  • Next by thread: Re: More elegance than a long if/else
  • Index(es):
    • Date
    • Thread