Main Area and Open Discussion > Living Room
robots are killing
anandcoral:
I needed a second go through the code to locate the mistake,
http://oppressive-silence.com/comics/oh-no-the-robots
That's why testing code is so important.
phitsc:
... and using up-to-date compilers with warning level set to max (and treat warnings as errors)
mwb1100:
That's why testing code is so important
-anandcoral (September 02, 2016, 07:31 AM)
--- End quote ---
But if you're building robots you should still let someone else perform the testing - what's in the comic *is* a test run.
ConstanceJill:
Huh, can anyone please explain the issue for non-programmers ? :p
(Other than the fact that there actually is a command to kill humans in the code, even if it probably wasn't supposed to be triggered.)
Deozaan:
Huh, can anyone please explain the issue for non-programmers ? :p
(Other than the fact that there actually is a command to kill humans in the code, even if it probably wasn't supposed to be triggered.)
-ConstanceJill (September 02, 2016, 12:58 PM)
--- End quote ---
The "if" statement assigns isCrazyMurderingRobot to true, instead of just comparing it to see if it is equal to true. Therefore it will never be false when that code executes, and the robots will never "be_nice_to" humans.
One equal sign (x = true) is an assignment. Two equal signs (x == true) is a comparison. It's a common mistake, even for experienced programmers.
Navigation
[0] Message Index
[#] Next page
Go to full version