Re: More elegance than a long if/else
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