diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-06-25 16:17:15 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-06-25 16:17:15 -0400 |
| commit | efb4760d85794b24d8c1dd1727ae374d499f240f (patch) | |
| tree | 7f9b5dd931a97388cdc192f6bd5f849c88dce99d /calc.go | |
| parent | ee56cc539398a7fc1664f39cf16428fa13c262c9 (diff) | |
| download | pfc-efb4760d85794b24d8c1dd1727ae374d499f240f.zip | |
don't panic if there are not enough operands
Diffstat (limited to 'calc.go')
| -rw-r--r-- | calc.go | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -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. |