code: public void step(int step, Closure closure) {
          if (step == 0) {
              if (compareTo(from, to) != 0) {
                  throw new GroovyRuntimeException("Infinite loop detected due to step size of 0");
              } else {
                  return; // from == to and step == 0, nothing to do, so return
              }
          }
  
          if (reverse) {
              step = -step;
          }
          if (step > 0) {
              Comparable first = from;
              Comparable value = from;
              while (compareTo(value, to) <= 0) {
                  closure.call(value);
                  for (int i = 0; i < step; i++) {
                      value = (Comparable) increment(value);
                      if (compareTo(value, first) <= 0) return;
                  }
              }
          } else {
              step = -step;
              Comparable first = to;
              Comparable value = to;
              while (compareTo(value, from) >= 0) {
                  closure.call(value);
                  for (int i = 0; i < step; i++) {
                      value = (Comparable) decrement(value);
                      if (compareTo(value, first) >= 0) return;
                  }
              }
          }
      }
docs: {@inheritDoc}