Pages: [1]   Go Down
Author Topic: Suggestion for online Reference  (Read 553 times)
0 Members and 1 Guest are viewing this topic.
Johannesburg. UTC+2
Online Online
Faraday Member
Karma: 113
Posts: 4942
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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.

switch (var) {
    case 1:
      //do something when var equals 1
    case 2:
    case 5:      <================================================
      //do something when var equals 2 OR 5  <======================
      // if nothing else matches, do the default
      // default is optional

The Elders of the Internet know who I am
I'm on LinkedIn:

South Texas
Offline Offline
Edison Member
Karma: 8
Posts: 1025
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Pages: [1]   Go Up
Jump to: