• robotica
    link
    fedilink
    13
    edit-2
    8 months ago

    Don’t forget that you can have fall-through cases, so you can simplify it even further:

    switch (number) {
        case 1:
        case 3:
        case 5:
        case 7:
        case 9:
          ...