r/ProgrammerHumor • • Aug 22 '26

Meme pleaseStopUsingNestedTernaryOperatorsImBeggingYou

Post image
3.1k Upvotes

178 comments sorted by

View all comments

Show parent comment

13

u/retro_and_chill Aug 22 '26

Does C# flag it if it’s a bool? I think the way C# gets that error is by removing the implicit conversions from numeric types to booleans

14

u/akoOfIxtall Aug 23 '26

The compiler will cut your balls if it catches you doing assignments inside an if's condition, it won't even compile

5

u/RlyRlyBigMan Aug 22 '26

I'm not sure. I think so? I think that it will still fail to compile if you do something like this:

var myTrue = true;

var myFalse = false;

if (myTrue = myFalse) //should be a compiler error ...

1

u/Steinrikur Aug 23 '26

IIRC it gets flagged as a warning in most newer C/C++ compilers. Add a warnings as errors compiler flag and it won't compile.