visitSetExpr method
Implementation
@override
Object? visitSetExpr(Expr.Set expr) {
Object? object = evaluate(expr.object);
Object? value = evaluate(expr.value);
if (object is LoxInstance) {
object.set(expr.name, value);
return value;
}
if (object is LoxSetCallable) {
object.set(expr.name, value);
return value;
}
throw RuntimeError(expr.name, "Only instances have set properties.");
}