Files
monkey/object/builtin_str.go
Chuck Smith d3471af03d
Some checks failed
Build / build (push) Successful in 9m45s
Test / build (push) Failing after 16m25s
int() bool() and str()
2024-03-21 15:19:48 -04:00

20 lines
344 B
Go

package object
import (
"fmt"
)
// Str ...
func Str(args ...Object) Object {
if len(args) != 1 {
return newError("wrong number of arguments. got=%d, want=1", len(args))
}
arg, ok := args[0].(fmt.Stringer)
if !ok {
return newError("argument to `str` not supported, got %s", args[0].Type())
}
return &String{Value: arg.String()}
}