splitByComma method

Tuple2<num, num?> splitByComma(
  1. num number
)

Splits a given number by it's comma, if it has one. Returns both parts of the number if a comma is present, otherwise returns the original number and null.

Implementation

Tuple2<num, num?> splitByComma(num number) {
  if (!hasComma(number)) {
    return Tuple2(number, null);
  }
  List<String> numParts = number.toString().split(".");
  assert(numParts.length == 2);
  return Tuple2(num.parse(numParts.first), num.tryParse(numParts.last));
}