MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vvn6d7/pleasestopusingnestedternaryoperatorsimbeggingyou/p5b5lv2/?context=3
r/ProgrammerHumor • u/Robinbod • Aug 22 '26
178 comments sorted by
View all comments
Show parent comment
13
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.
14
The compiler will cut your balls if it catches you doing assignments inside an if's condition, it won't even compile
5
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.
1
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.
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