forceBetween method

int forceBetween(
  1. int from,
  2. int to
)

Ensure NOT this greater than or equal to from and less than or equal to to?

Implementation

int forceBetween(int from, final int to) {
  if (from > to) {
    return this;
  }

  if (this < from) {
    return from;
  }

  if (this > to) {
    return to;
  }

  return this;
}