public void Assign(Token name, object value) { if (!Values.ContainsKey(name.Lexeme)) { if (Enclosing != null) { Enclosing.Assign(name, value); return; } throw new RuntimeException(name, $"Undefined variable '{name.Lexeme}'."); } Values[name.Lexeme] = value; }
public void Assign(string name, object value) { if (Values.ContainsKey(name)) { Values[name] = value; } else if (Enclosing != null) { Enclosing.Assign(name, value); } else { throw new RuntimeException($"Variable '{name}' is not defined!"); } }