Implement != operator in expression evaluator

This commit is contained in:
Elara 2023-12-22 15:43:49 -08:00
parent 687e0a6c36
commit 4309bcc3b4
1 changed files with 2 additions and 0 deletions

View File

@ -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")