|Home | Tutorial | Classes | Functions | QSA Workbench | Language | Qt API | QSA Articles | Qt Script for Applications |

[Prev: continue] [Home] [Next: do]

### default

    switch ( expression ) {
        case 1 :
            Statements1;
            break;
        default :
            DefaultStatements;
            break;
    }

This keyword is used in switch statements. It is used instead of case to match anything that the `switch` statement's expression has evaluated to. If no `default` is used, and none of the cases match, then the `switch` statement will not execute anything and control will pass on to the following statement. If `default` is used, it must be the last case in the `switch` statement. This is because each `case` is evaluated in order, and since `default` matches any value, it will always be executed if the interpreter reaches it, and any following cases would always be ignored. When the `default` case is encountered its DefaultStatements are executed. It is customary to end a `default` statement with a break.

See switch for an example.

[Prev: continue] [Home] [Next: do]