From 4309bcc3b4360d3964a96cab8c3bbe367a0f2fc8 Mon Sep 17 00:00:00 2001 From: Elara6331 Date: Fri, 22 Dec 2023 15:43:49 -0800 Subject: [PATCH] Implement != operator in expression evaluator --- expr.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/expr.go b/expr.go index 1bc8e82..e667261 100644 --- a/expr.go +++ b/expr.go @@ -63,6 +63,8 @@ func (t *Template) performOp(a, b reflect.Value, op ast.Operator) (any, error) { switch op.Value { case "==": return a.Equal(b), nil + case "!=": + return !a.Equal(b), nil case "&&": if a.Kind() != reflect.Bool || b.Kind() != reflect.Bool { return nil, ast.PosError(op, "logical operations may only be performed on boolean values")