Files
monkey/internal/builtins/oct.go
Chuck Smith 12d43c9835
Some checks failed
Publish Image / publish (push) Waiting to run
Test / build (push) Waiting to run
Build / build (push) Has been cancelled
Refactor Type to be an int
2024-03-29 11:01:15 -04:00

23 lines
429 B
Go

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