aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calc.go9
-rw-r--r--ui.go4
2 files changed, 4 insertions, 9 deletions
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.
diff --git a/ui.go b/ui.go
index bd39eaf..4d121a7 100644
--- a/ui.go
+++ b/ui.go
@@ -54,9 +54,7 @@ func (ui UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
ui.calc.negate()
case "+", "-", "*", "/", "%", "^":
operator := msg.String()[0]
- if err := ui.calc.performOperation(operator); err != nil {
- panic(err)
- }
+ ui.calc.performOperation(operator)
case "backspace":
if len(ui.calc.buf) > 0 {
ui.calc.buf = ui.calc.buf[:len(ui.calc.buf)-1]