DEV Community

Discussion on: I Am Not A Real Programmer

Collapse
 
kimmohito profile image
Kim Mohito • Edited

The obvious mistake is on if(isCrazyMurderingRobot = true),

We should use == to check if the variable is set
while using = to assign the value

I'm not sure in other languages, but I think you should have nested curly brackets {} for every if(condition).

The correct way to code is

static bool isCrazyMurderingRobot = false;

void interact_with_humans (void){
  if(isCrazyMurderingRobot == true){
    kill(humans);
  }
  else{
    be_nice_to(humans);
  }
}
Enter fullscreen mode Exit fullscreen mode

For more details, please check these descriptions (they are for the C# language, but the operators behave similar in other languages like PHP, Java etc