Rat constructor

Rat(
  1. BigInt n, [
  2. BigInt? m
])

Creates a new Rat with the given numerator and denominator.

Implementation

factory Rat(BigInt n, [BigInt? m]) {
  m ??= BigInt.one;
  if (m == BigInt.zero) {
    throw ArgumentError.value(m, 'm', 'cannot be zero');
  } else if (m < BigInt.zero) {
    n = -n;
    m = -m;
  }

  return Rat._(n, m);
}