diff --git a/src/com/craftinginterpreters/lox/Interpreter.java b/src/com/craftinginterpreters/lox/Interpreter.java index 24cf1c0..57e697c 100644 --- a/src/com/craftinginterpreters/lox/Interpreter.java +++ b/src/com/craftinginterpreters/lox/Interpreter.java @@ -110,6 +110,14 @@ class Interpreter implements Expr.Visitor { return (String) left + (String) right; } + if (left instanceof String) { + return (String) left + stringify(right); + } + + if (right instanceof String) { + return stringify(left) + (String) right; + } + throw new RuntimeError(expr.operator, "Operands must be two numbers or two strings."); case SLASH: checkNumberOperands(expr.operator, left, right);