Simplified Equality
Some checks failed
Build / build (push) Successful in 10m48s
Test / build (push) Failing after 17m11s

This commit is contained in:
Chuck Smith
2024-03-24 17:11:48 -04:00
parent fea9fb9f64
commit 1c99d2198b
11 changed files with 109 additions and 133 deletions

View File

@@ -9,24 +9,29 @@ type String struct {
func (s *String) Type() ObjectType {
return STRING_OBJ
}
func (s *String) Inspect() string {
return fmt.Sprintf("%#v", s.Value)
}
func (s *String) Clone() Object {
return &String{Value: s.Value}
}
func (s *String) String() string {
return s.Value
}
func (s *String) Equal(other Object) bool {
func (s *String) Compare(other Object) int {
if obj, ok := other.(*String); ok {
return s.Value == obj.Value
switch {
case s.Value < obj.Value:
return -1
case s.Value > obj.Value:
return 1
default:
return 0
}
}
return false
}
func (s *String) Less(other Object) bool {
if obj, ok := other.(*String); ok {
return s.Value < obj.Value
}
return false
return 1
}