Files
monkey/object/builtin_exit.go
Chuck Smith 43362475f9
Some checks failed
Build / build (push) Successful in 10m0s
Test / build (push) Failing after 16m20s
seperated builtins
2024-03-20 17:01:45 -04:00

18 lines
304 B
Go

package object
import "os"
// Exit ...
func Exit(args ...Object) Object {
if len(args) == 1 {
if args[0].Type() != INTEGER_OBJ {
return newError("argument to `exit` must be INTEGER, got %s",
args[0].Type())
}
os.Exit(int(args[0].(*Integer).Value))
} else {
os.Exit(0)
}
return nil
}