assign method

void assign(
  1. Token name,
  2. Object? value
)

Implementation

void assign(Token name, Object? value) {
  if (values.containsKey(name.lexeme)) {
    values[name.lexeme] = value;
    return;
  }
  if (enclosing != null) {
    enclosing!.assign(name, value);
    return;
  }
  throw RuntimeError(name, "Undefined variable '" + name.lexeme + "'.");
}