Default

From Wiring

Revision as of 19:34, 9 March 2012 by Bones.charles (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Name default
Description Keyword for defining the default condition of a switch(). If none of the case labels match the switch() parameter, the statement(s) after the default syntax are executed. Switch structures don't require a default.
Syntax
default: statements
Methods
Constructor
Parameters
statements unknown datatype one or more valid statements to be executed
Returns
Example
char letter = 'F';
 
switch(letter) {
  case 'A': 
    Serial.println("Alpha");  // Does not execute
    break;
  case 'B': 
    Serial.println("Bravo");  // Does not execute
    break;
  default:
    Serial.println("Zulu");   // Prints Zulu
    break;
}
Related switch, break, case
Language: English  • Español
Personal tools