assertInt method

int assertInt(
  1. [String? name]
)

Returns value as an int, if it's an integer value according to isInt.

Throws a SassScriptException if value isn't an integer. If this came from a function argument, name is the argument name (without the $). It's used for error reporting.

Implementation

int assertInt([String? name]) {
  if (fuzzyAsInt(value) case var integer?) return integer;
  throw SassScriptException("$this is not an int.", name);
}