From cf9e39ba961cb03ad91d7eb56021636b329d9828 Mon Sep 17 00:00:00 2001 From: tacheraSasi Date: Sun, 8 Dec 2024 01:19:04 +0300 Subject: [PATCH] added an eq method in the builtins **eq** --- evaluator/builtins.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/evaluator/builtins.go b/evaluator/builtins.go index 5f97176..a0a5e7c 100755 --- a/evaluator/builtins.go +++ b/evaluator/builtins.go @@ -148,6 +148,22 @@ var builtins = map[string]*object.Builtin{ }, }, + "eq":{ + Fn: func (args ...object.Object)object.Object { + if len(args) !=2{ + return newError("Sorry, convert requires 2 arguments, you provided %d", len(args)) + } + + a := args[0] + b := args[1] + + if a == b { + return &object.Boolean{Value:true} + } + return &object.Boolean{Value:false} + }, + }, + "convert": { Fn: func(args ...object.Object) object.Object { if len(args) != 2 {