visitLogicalExpr method

  1. @override
Object? visitLogicalExpr(
  1. Logical expr
)
override

Implementation

@override
Object? visitLogicalExpr(Expr.Logical expr) {
  Object? left = evaluate(expr.left);
  if (expr.operator.type == TokenType.OR) {
    if (isTruthy(left)) {
      return left;
    }
  } else {
    if (!isTruthy(left)) {
      return left;
    }
  }
  return evaluate(expr.right);
}