Go Down

Topic: Suggestion for online Reference (Read 599 times) previous topic - next topic

JimboZA

Hi,

I asked elsewhere about how to do the same actions for different cases in switch case and Arrch told me how to do it. I think an example like this would be good... ie, adding the arrowed parts below to the existing example.

Code: [Select]
switch (var) {
    case 1:
      //do something when var equals 1
      break;
    case 2:
    case 5:      <================================================
      //do something when var equals 2 OR 5  <======================
      break;
    default:
      // if nothing else matches, do the default
      // default is optional
  }

kf2qd

I agree - I have done all that stuff in the past but not being a production programmer I do need some reminding myself, from time to time.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy