coerce method

SassNumber coerce(
  1. List<String> newNumerators,
  2. List<String> newDenominators, [
  3. String? name
])

Returns a copy of this number, converted to the units represented by newNumerators and newDenominators.

This does not throw an error if this number is unitless and newNumerators/newDenominators are not empty, or vice versa. Instead, it treats all unitless numbers as convertible to and from all units without changing the value.

Note that coerceValue is generally more efficient if the value is going to be accessed directly.

Throws a SassScriptException if this number's units aren't compatible with newNumerators and newDenominators.

If this came from a function argument, name is the argument name (without the $). It's used for error reporting.

Implementation

SassNumber coerce(List<String> newNumerators, List<String> newDenominators,
        [String? name]) =>
    SassNumber.withUnits(coerceValue(newNumerators, newDenominators, name),
        numeratorUnits: newNumerators, denominatorUnits: newDenominators);