From efb4760d85794b24d8c1dd1727ae374d499f240f Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Tue, 25 Jun 2024 16:17:15 -0400 Subject: don't panic if there are not enough operands --- calc.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'calc.go') diff --git a/calc.go b/calc.go index 2fb1699..47ece5b 100644 --- a/calc.go +++ b/calc.go @@ -51,20 +51,17 @@ func (c *Calculator) negate() { } // performOp performs the specified arithmetic operation. -func (c *Calculator) performOperation(operator byte) error { +func (c *Calculator) performOperation(operator byte) { fn, err := parseOperator(operator) if err != nil { - return err + return } - lhs, rhs, err := c.operands() if err != nil { - return err + return } - c.stack.push(fn(lhs, rhs)) c.buf = "" - return nil } // operands returns the left and right operands, or error if there are not enough. -- cgit v1.2.3