Software, technology, sysadmin war stories, and more. Feed
Saturday, September 1, 2012

PEMDAS... or just hit the programmer with a large stick

How well do you know your C++ operator precedence rules?

int count = 0;
if (it != purple_monkey_dishwasher_.end()) {
  for (int i = 0; i < (it->second).size(); ++i) {
    if (SYSTIME->Now() - (it->second)[i] < kOneDay) {

SYSTIME->Now() is a double. kOneDay is an int with a (non-leap-second) day's worth of seconds.

purple_monkey_dishwasher_ has been renamed to protect the guilty.

I had to stare at that one for a while to make sure I understood it.