UUUuuuuuh, I am not a programmer (you’re going to say “thank god”), but…
I sometimes even chain them. You can put yet another ternary operator in the else and keep going. You know, else-if.
So anyway, I can get ternary operators spanning 2 - 3 lines.
Oh, I also often have issues thinking of proper loops, so you’d see a few terribly used goto statements.
Although I do remove ones that are obvious brain fart.
For example, quite obvious
voidexample(bool true_or_false){
if(true_or_false){
//code if true
}
else{
//code if false
}
//other code
}
Well, I’ve already had my brain goof up even that once or twice. “How the fuck”, you’re asking?
voidexample(bool true_or_false){
if(true_or_false){
goto if_true;
}
//code if falsegoto end_false_if;
if_true:
//code if true
end_false_if:
//other code
}
One of my coworkers is fond of using ternary expressions instead of “if” blocks. Even ones without an “else”. So I see things like:
condition ? someVar = "blah" : null;or
condition ? doSomething() : nullWhich should both just use “if” statements. Or my favorite:
condition ? someVar = "foo" : someVar = "bar"which should really be
someVar = condition ? "foo" : "bar"UUUuuuuuh, I am not a programmer (you’re going to say “thank god”), but…
I sometimes even chain them. You can put yet another ternary operator in the else and keep going. You know, else-if.
So anyway, I can get ternary operators spanning 2 - 3 lines.
Oh, I also often have issues thinking of proper loops, so you’d see a few terribly used
gotostatements.Although I do remove ones that are obvious brain fart.
For example, quite obvious
void example(bool true_or_false){ if(true_or_false){ //code if true } else{ //code if false } //other code }Well, I’ve already had my brain goof up even that once or twice. “How the fuck”, you’re asking?
void example(bool true_or_false){ if(true_or_false){ goto if_true; } //code if false goto end_false_if; if_true: //code if true end_false_if: //other code }The brain-fart if-else.
You need another goto end right before the end_false_if:, otherwise the false code will always run
I tested it, it works as it is.
#include <stdio.h> #include <stdbool.h> void main(){ bool true_or_false = true; if(true_or_false){ goto if_true; } printf("This code runs only if false.\n"); goto end_false_if; if_true: printf("This code runs only if true.\n"); end_false_if: printf("This code always runs.\n"); }If true, it jumps to if_true, then runs other code. If false, the if gets skipped, if false code gets run, then it skips over if true code.
I totally did the thing where I commented without reading properly before. Sorry!
Dear lord lmao
The last thing, that would be a “request changes” for me.
I haven’t seen him do it lately in any code I’ve reviewed but I do change it whenever I see it if I’m doing work nearby lol