diff options
Diffstat (limited to 'calc.go')
| -rw-r--r-- | calc.go | 10 |
1 files changed, 3 insertions, 7 deletions
@@ -61,17 +61,13 @@ func (c *Calculator) negate() { } } -// performOp performs the specified arithmetic operation. -func (c *Calculator) performOperation(operator byte) { - fn, err := parseOperator(operator) - if err != nil { - return - } +// operate performs a binary arithmetic operation on the stored values. +func (c *Calculator) operate(op Op) { lhs, rhs, err := c.operands() if err != nil { return } - c.stack.push(fn(lhs, rhs)) + c.stack.push(op(lhs, rhs)) c.buf = "" } |