About switch case statements...

Walter Bright newshound1 at digitalmars.com
Sun Nov 15 11:25:24 PST 2009


Michel Fortin wrote:
> Hum two suggestions. Sometime I want fall-through when I write a switch, 
> but I always make it clear that it isn't a bug by writing the intent in 
> a short comment:
> 
>     switch (c) {
>         case 1:
>             blah();
>             break;
>         case 2:
>             blah();
>             // fallthrough
>         case 3:
>             blah();
>             break;
>     }

I just use whitespace:

      switch (c) {
          case 1:
              blah();
              break;

          case 2:
              blah();
          case 3:
              blah();
              break;
      }

Works fine.



More information about the Digitalmars-d mailing list