Files
monkey/object/str.go
Chuck Smith 1c99d2198b
Some checks failed
Build / build (push) Successful in 10m48s
Test / build (push) Failing after 17m11s
Simplified Equality
2024-03-24 17:11:48 -04:00

38 lines
541 B
Go

package object
import "fmt"
type String struct {
Value string
}
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) Compare(other Object) int {
if obj, ok := other.(*String); ok {
switch {
case s.Value < obj.Value:
return -1
case s.Value > obj.Value:
return 1
default:
return 0
}
}
return 1
}