public object Get(Token name) { if (Values.ContainsKey(name.Lexeme)) { return(Values[name.Lexeme]); } if (Enclosing != null) { return(Enclosing.Get(name)); } throw new RuntimeError(name, $"Undefined variable '{name.Lexeme}'."); }
public object Get(Token name) { if (Values.TryGetValue(name.Lexeme, out var value)) { return(value); } if (Enclosing != null) { return(Enclosing.Get(name)); } throw new RuntimeError(name, $"Undefined variable '{name.Lexeme}'."); }
public object Get(Token name) => Values.TryGetValue(name.Lexeme, out var v) ? v : Enclosing != null ? Enclosing.Get(name) : throw new RuntimeException(name, $"Undefined variable {name.Lexeme}.");