Click here to Skip to main content
15,879,844 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
Nelek2-Mar-24 2:11
protectorNelek2-Mar-24 2:11 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
Amarnath S2-Mar-24 5:58
professionalAmarnath S2-Mar-24 5:58 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
trønderen2-Mar-24 7:58
trønderen2-Mar-24 7:58 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
Gary R. Wheeler2-Mar-24 4:46
Gary R. Wheeler2-Mar-24 4:46 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
Rage3-Mar-24 7:50
professionalRage3-Mar-24 7:50 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
Gary R. Wheeler3-Mar-24 9:06
Gary R. Wheeler3-Mar-24 9:06 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
trønderen3-Mar-24 10:09
trønderen3-Mar-24 10:09 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
Daniel Pfeffer2-Mar-24 6:33
professionalDaniel Pfeffer2-Mar-24 6:33 
It always pays to cover all bases!

Every switch statement that I write contains a default clause. This is true even when switching on an enumerated type, because the underlying variable is an int (or another integral type), and it is possible that the value got corrupted.
C++
enum {SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY} weekday;

weekday = SATURDAY;
++weekday; /* generates error in switch statement below */

switch (weekday)
{
case SUNDAY: ...; break;
case MONDAY: ...; break;
case TUESDAY: ...; break;
case WEDNESDAY: ...; break;
case THURSDAY: ...; break;
case FRIDAY: ...; break;
case SATURDAY: ... break;
default: report("weekday out of bounds!"); /* report error */
}
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.

JokeRe: Sometimes It Pays To Cover All Bases Pin
Nelek2-Mar-24 7:35
protectorNelek2-Mar-24 7:35 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
trønderen2-Mar-24 8:30
trønderen2-Mar-24 8:30 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
Nelek3-Mar-24 0:50
protectorNelek3-Mar-24 0:50 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
trønderen3-Mar-24 1:50
trønderen3-Mar-24 1:50 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
mdblack984-Mar-24 2:12
mdblack984-Mar-24 2:12 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
Derek Hunter4-Mar-24 2:38
Derek Hunter4-Mar-24 2:38 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
glennPattonWork34-Mar-24 8:49
professionalglennPattonWork34-Mar-24 8:49 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
Steve Naidamast4-Mar-24 4:04
professionalSteve Naidamast4-Mar-24 4:04 
GeneralWhen is a backup not a backup? PinPopular
theoldfool29-Feb-24 23:43
professionaltheoldfool29-Feb-24 23:43 
GeneralRe: When is a backup not a backup? Pin
Ron Anders1-Mar-24 1:54
Ron Anders1-Mar-24 1:54 
GeneralRe: When is a backup not a backup? Pin
theoldfool1-Mar-24 3:33
professionaltheoldfool1-Mar-24 3:33 
GeneralRe: When is a backup not a backup? Pin
DerekT-P1-Mar-24 2:04
professionalDerekT-P1-Mar-24 2:04 
GeneralRe: When is a backup not a backup? Pin
dandy721-Mar-24 4:04
dandy721-Mar-24 4:04 
GeneralRe: When is a backup not a backup? Pin
theoldfool1-Mar-24 7:49
professionaltheoldfool1-Mar-24 7:49 
GeneralRe: When is a backup not a backup? Pin
dandy721-Mar-24 7:54
dandy721-Mar-24 7:54 
GeneralRe: When is a backup not a backup? Pin
Nelek1-Mar-24 9:01
protectorNelek1-Mar-24 9:01 
GeneralRe: When is a backup not a backup? Pin
dandy721-Mar-24 10:10
dandy721-Mar-24 10:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.