Skip to content

Commit

Permalink
Update EvalIfExpression.php
Browse files Browse the repository at this point in the history
  • Loading branch information
KennedyTedesco committed Jul 23, 2023
1 parent 2982658 commit 5513189
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Evaluator/EvalIfExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ public function __invoke(IfExpression $ifExpression): MonkeyObject

return match (true) {
$monkeyObject instanceof ErrorObject => $monkeyObject,
(bool)$monkeyObject->value => $this->evaluator->eval($ifExpression->consequence, $this->environment),
$ifExpression->alternative instanceof BlockStatement => $this->evaluator->eval($ifExpression->alternative, $this->environment),

(bool)$monkeyObject->value() =>
$this->evaluator->eval($ifExpression->consequence, $this->environment),

$ifExpression->alternative instanceof BlockStatement =>
$this->evaluator->eval($ifExpression->alternative, $this->environment),

default => NullObject::instance(),
};
}
Expand Down

0 comments on commit 5513189

Please sign in to comment.