DEV Community

Discussion on: I Am Not A Real Programmer

Collapse
 
qm3ster profile image
Mihail Malo • Edited

I only see the assignment operator used instead of the equality operator, which tragically also yields the assigned value.
What are the other 2?

What mistakes are there in

static bool isCrazyMurderingRobot = false;

void interact_with_humans (void) {
  if (isCrazyMurderingRobot)
    kill(humans);
  else
    be_nice_to(humans);
}
Collapse
 
workmad3 profile image
David Workman

'humans' appears to be undefined, and it's either a missing closing } or poor indentation on the else clause.

So I'm surprised this compiled :)

Thread Thread
 
qm3ster profile image
Mihail Malo

it's either a missing closing } or poor indentation on the else clause

Butt where? :o

static bool isCrazyMurderingRobot = false;

void interact_with_humans (void) {
  if (isCrazyMurderingRobot = true)
    kill(humans);
  else
    be_nice_to(humans);
}
Thread Thread
 
workmad3 profile image
David Workman

Oops, my bad... I managed to insert braces around the clauses in my memory.

Collapse
 
stargator profile image
Stargator

I would suggest they never have the kill() function. Just doesn't make sense to give a robot the ability to kill. :)

Thread Thread
 
qm3ster profile image
Mihail Malo

What if a criminal, or even a non-human animal is posing a threat to the owner? Shouldn't they kill(perpetrator)?

Thread Thread
 
mikeeus profile image
Mikias Abera

They should administerBearMace(animal)

Thread Thread
 
qm3ster profile image
Mihail Malo

Why would an android assistant for grannies contain bear mace?
Sounds scary.

Thread Thread
 
mikeeus profile image
Mikias Abera

Lol well why would an android assistant for grannies kill animals? No one is innocent here

Thread Thread
 
qm3ster profile image
Mihail Malo

Because the granny is in imminent danger, and it's the best effort it can make with the general purpose mobility functions.