refactor objects
Some checks failed
Publish Image / publish (push) Waiting to run
Test / build (push) Waiting to run
Build / build (push) Has been cancelled

This commit is contained in:
2024-04-01 17:34:10 -04:00
parent 803f330e82
commit 99f7553d67
15 changed files with 101 additions and 94 deletions

View File

@@ -2,6 +2,7 @@ package object
import (
"fmt"
"hash/fnv"
"strings"
"unicode/utf8"
)
@@ -26,10 +27,18 @@ func (s String) Inspect() string {
return fmt.Sprintf("%#v", s.Value)
}
func (s String) Clone() Object {
func (s String) Copy() Object {
return String{Value: s.Value}
}
// Hash implements the Hasher interface
func (s String) Hash() HashKey {
h := fnv.New64a()
h.Write([]byte(s.Value))
return HashKey{Type: s.Type(), Value: h.Sum64()}
}
func (s String) String() string {
return s.Value
}