pingPong<T extends num> static method

num pingPong<T extends num>(
  1. T x, {
  2. int length = 1,
})

Implementation

static num pingPong<T extends num>(T x, {int length = 1}) {
  return length - Math.abs(x % (length * 2) - length);
}