Click here to Skip to main content
15,887,683 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Both Weird & Wonderful - a W10 Surprise Pin
TnTinMn21-Aug-20 7:22
TnTinMn21-Aug-20 7:22 
GeneralRe: Both Weird & Wonderful - a W10 Surprise Pin
Rick York21-Aug-20 9:16
mveRick York21-Aug-20 9:16 
GeneralRe: Both Weird & Wonderful - a W10 Surprise Pin
patbob21-Aug-20 14:19
patbob21-Aug-20 14:19 
GeneralGoogle Docs and inline images (CP related) Pin
raddevus12-Aug-20 10:34
mvaraddevus12-Aug-20 10:34 
Generalinvert if : visual studio code helper Pin
raddevus4-Aug-20 5:15
mvaraddevus4-Aug-20 5:15 
GeneralRe: invert if : visual studio code helper Pin
honey the codewitch4-Aug-20 5:41
mvahoney the codewitch4-Aug-20 5:41 
GeneralRe: invert if : visual studio code helper Pin
raddevus4-Aug-20 6:02
mvaraddevus4-Aug-20 6:02 
GeneralRe: invert if : visual studio code helper Pin
Mircea Neacsu4-Aug-20 8:23
Mircea Neacsu4-Aug-20 8:23 
This is not a true case of yoda conditionals or at least not in the sense I've heard the term.

For me, yoda conditionals are written like:
C++
if (1 >= args.Length)
{
  Console.Write ("Not enough arguments");
  return;
}

The inversion refers to the order of terms in the if and the reason for it is that a construct like:
C++
if (1 = args.Length)

(note the missing equal sign)
will get you slapped with a big fat error message ('1' is not a l-value). The "normal" order might or might not produce a warning depending on compiler's whims.

In your case it's just a case of compiler being annoying. Sometime I feel it's becoming almost like Clippy: "It seems you want to write an if statemenet. Do you need help with that?".

Here is a random example taken straight out of some code:
C++
assert (str);
while (*str > 0 && *str <= ' ')
  str++;

And it flags the while statement with an IntelliSense warning: "Dereferencing NULL pointer". Heck no! That's why I put the assert right before it.
Mircea

GeneralRe: invert if : visual studio code helper Pin
Nelek4-Aug-20 19:42
protectorNelek4-Aug-20 19:42 
GeneralRe: invert if : visual studio code helper Pin
SteakhouseLuke5-Aug-20 4:44
SteakhouseLuke5-Aug-20 4:44 
GeneralRe: invert if : visual studio code helper Pin
Nelek5-Aug-20 6:55
protectorNelek5-Aug-20 6:55 
GeneralRe: invert if : visual studio code helper Pin
englebart23-Aug-20 8:01
professionalenglebart23-Aug-20 8:01 
GeneralRe: invert if : visual studio code helper Pin
Mircea Neacsu23-Aug-20 9:03
Mircea Neacsu23-Aug-20 9:03 
GeneralRe: invert if : visual studio code helper Pin
Maximilien4-Aug-20 5:52
Maximilien4-Aug-20 5:52 
GeneralRe: invert if : visual studio code helper Pin
raddevus4-Aug-20 6:04
mvaraddevus4-Aug-20 6:04 
GeneralRe: invert if : visual studio code helper Pin
Nelek4-Aug-20 8:18
protectorNelek4-Aug-20 8:18 
GeneralRe: invert if : visual studio code helper Pin
raddevus4-Aug-20 8:39
mvaraddevus4-Aug-20 8:39 
GeneralRe: invert if : visual studio code helper Pin
Jon McKee4-Aug-20 10:44
professionalJon McKee4-Aug-20 10:44 
GeneralRe: invert if : visual studio code helper Pin
raddevus4-Aug-20 11:40
mvaraddevus4-Aug-20 11:40 
GeneralRe: invert if : visual studio code helper Pin
Jon McKee4-Aug-20 12:11
professionalJon McKee4-Aug-20 12:11 
GeneralRe: invert if : visual studio code helper Pin
raddevus4-Aug-20 16:43
mvaraddevus4-Aug-20 16:43 
GeneralRe: invert if : visual studio code helper Pin
Richard Deeming4-Aug-20 23:41
mveRichard Deeming4-Aug-20 23:41 
GeneralRe: invert if : visual studio code helper Pin
raddevus5-Aug-20 2:14
mvaraddevus5-Aug-20 2:14 
GeneralRe: invert if : visual studio code helper Pin
Jon McKee12-Aug-20 11:14
professionalJon McKee12-Aug-20 11:14 
GeneralRe: invert if : visual studio code helper Pin
Richard Deeming12-Aug-20 22:18
mveRichard Deeming12-Aug-20 22:18 

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.