if(isCrazyMuderingRobot = true)
Not sure what that language is (java?) but the conditional check looks like an affectation to me, which should lead to nothing at all (compilation error)
Besides I'm not sure how that ";" after kill(humans) would work right before an else without brackets...
It looks like C code to me. That part should compile just fine with C or C++, but although the compiler gives you a warning these days it allows you to confuse assignments with comparisons. The expression will read the value from the left side of the assignment in the evaluation. Sometimes it's convenient to do that to get some things done (Python added the walrus operator to let you do it safely), but it's usually a mistake.
> it allows you to confuse assignments with comparisons
I don't see a case where such "permission" could lead to any desirable outcome whatsoever, it's lame
Yeah, it's considered bad form to use assignment operators in conditional statements. Even if you know what you're doing when you write the code it could cause confusion for the team that has to deal with it (or even the programmer who wrote once they've forgotten what they meant to do).
As far as I know they didn't design C with the intent of allowing programmers to write convenient but dangerous code, but it just happened to work out that way with the basic syntax they came up with. Later languages like Python reworked the rules so programmers would no longer be able to make that common mistake (or at least make it less likely to happen).
(post is archived)