• robotica
    link
    fedilink
    13
    edit-2
    1 year 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:
          ...