refactor objects
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user