switch()

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Mon Feb 17 21:30:33 PST 2014


On 2/16/2014 10:59 PM, Manu wrote:
> On 17 February 2014 03:14, Timon Gehr <timon.gehr at gmx.ch> wrote:
>>
>> int difficulty=-1;
>>
>> switch(e.note.note){
>>      case 60: .. case 71:  difficulty = 0; break;
>>      case 72: .. case 83:  difficulty = 1; break;
>>      case 84: .. case 95:  difficulty = 2; break;
>>      case 96: .. case 107: difficulty = 3; break;
>>      default: break;
>> }
>>
>
> I hate this. It violates the formatting conventions used EVERYWHERE else.
> In terms of formatting, it doesn't even look like the same language.

I find it extremely easy to read, and much nicer than the other options. 
Being able to omit break and use switch as an expression would be a 
little nicer still, but I still fail to see why the above, no matter how 
it's formatted, is so terribly intolerable.



More information about the Digitalmars-d mailing list