Files
monkey/builtins/oct.go
Chuck Smith 6d234099d1
Some checks failed
Build / build (push) Successful in 11m16s
Test / build (push) Failing after 17m0s
type checking and error handling for builtins improved.
2024-03-25 16:18:08 -04:00

23 lines
411 B
Go

package builtins
import (
"fmt"
"monkey/object"
"monkey/typing"
"strconv"
)
// Oct ...
func Oct(args ...object.Object) object.Object {
if err := typing.Check(
"oct", args,
typing.ExactArgs(1),
typing.WithTypes(object.INTEGER_OBJ),
); err != nil {
return newError(err.Error())
}
i := args[0].(*object.Integer)
return &object.String{Value: fmt.Sprintf("0%s", strconv.FormatInt(i.Value, 8))}
}