File Under: Glossary

Loop

A loop is like a programming thought. Say you’re a police officer using a radar gun to catch speeding motorists. If the speed limit is 55 miles per hour, you might say to yourself: “If a car makes my radar gun display a higher value than 55, I’ll pull them over, but until then I will continue to take readings. And perhaps snack on this cruller.” In programming, the statement of this loop would be the action (firing up your motorcycle and chasing the speeder), and the expression would be the evaluation of whether or not the passing car made your radar gun read higher than 55. This is an example of a “while” loop:

  while (carSpeed < 55) {

  carSpeed = readRadar();

  // note:readRadar() should return the latest carSpeed

}



pullEmOver();  // this will only execute once carSpeed is >= 55