If this were a Node module, I wouldn’t even be surprised.
Clearly it should be
return orig == val
Duh
To match the current behavior it should be orig != val
You’re hired. Can your start on Monday?
Two wrongs don’t make a right, but sometimes in programming, two bugs can cancel each other out.
Whoever wrote this is more than capable of using it incorrectly.
Straight from the famous book “Making LOCs for Dummies”
WTAF? Is this written by a hallucinating AI?
I think it’s a joke (maybe)
I’ve asked ChatGPT to create boiler plate code and it will offer these nested functions so you can change the logic in the future. It’s not smart enough to ask why you’re doing something a particular way or suggest a better alternative.
I misread it as CompareBolians. No more Star Trek memes for me today.
Many Bolians died bringing us this information.
There’s no way, that’s so insane it has layers.
At first, I thought the shitty methods were the joke 😱😱😱
Those are rookie lines of code numbers right there.
I would have done it without the==
internal static bool AreBooleansEqual(bool orig, bool val) { if(orig) { if(val) return false return true } if(val) return true return false }
Don’t know why their code returns false when they are equal but I’m not going to dig through old code to refactor to use true instead of false.
Put more curly brackets around your if (val) true statement for 4 more lines, put elses in there for more lines even.
I should have created a local variable to store the result variable and return after the if statements. I just couldn’t help to make it look partially nice. My brain just doesn’t think at this high caliber of LOC optimizations.
New optimized LOC version:
internal static bool AreBooleansEqual(bool orig, bool val) { bool result; if(orig) { if(val) { result = false; } else { result = true; } } else { if(val) { result = true; } else { result = false; } } return result; }
My previous LOC: 12
New LOC version: 27
you can also use XOR operation
return (X || Y) && !(X && Y)
I was debating on bitwise operations, but decided on super basic if statements which I think the compiler would optimize, happy to see the logical operation form too
“We need to obfuscate our code to prevent reverse engineering”
The obfuscation in question:
We affectionately called it “subscurity” on the FE team.
When our BE apis would not give us any information why something failed, nor would they give us access to their logs. Complete black box of undocumented doodoo, and they would proudly say “security through obscurity” every time we asked why they couldn’t make improvements to usability.
bool ButAreTheyReallyEqualThough(bool orig, bool val)
Reminds me of is-even
Weekly downloads: 152,124
It’s dependent on is-odd which is dependent on is-number which has 88 million weekly downloads…
Where are the unit tests?
Don’t do OOP kids
That’s not OO code
Still good advice, though.
Not really. Good advice would be to use the right tool for the job
Not even once
This is your brain when you OD on OOP.