D Documentation  
Switch-Statement
The switch-statement provides a more structured way of catching multiple conditions in a single block.

switch( /* variable */ )
{
// if ( variable == 0)
  case 0:
    statement;
    break;

// if ( (variable == 1) || (variable == 2) || (variable == 3) || (variable == 4) )
  case 1,2,3,4:
    statement;
    break;

// if (! (std.string.strcmp(variable,"hello") || std.string.strcmp(variable,"world")) )
  case "hello", "world":
    statement;
    break;

// "else"
  default:
    statement;
    break;
}


The only 'disadvantage' of switch-statements is the need of constant values in the case-conditions. Apart from that you can use every (constant) type which is implicity convertible to the variable you want to evaluate.

Created using PHP docwiki written by Markus Dangl. Best viewed with Mozilla Firefox.