Skip to content

switch case logic  #8

Open
Open
@uxrkhan

Description

@uxrkhan

The switch case explanation is a bit misleading . There should be a break statement after every case for it to function as an if-else statement, otherwise it will evaluate all the cases.

switch (x) {                  // x must be int
    case X1: a; break;        // If x == X1 (must be a const), jump here
    case X2: b; break;        // Else if x == X2, jump here
    default: c;               // Else jump here (optional)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions