Skip to content

Commit

Permalink
define Null object (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
JunNishimura committed Sep 29, 2024
1 parent dc98b27 commit f93a329
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions evaluator/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

var (
Null = &object.Null{}
True = &object.Boolean{Value: true}
False = &object.Boolean{Value: false}
)
Expand Down
6 changes: 6 additions & 0 deletions object/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const (
INTEGER_OBJ = "INTEGER"
BOOLEAN_OBJ = "BOOLEAN"
ARRAY_OBJ = "ARRAY"
NULL_OBJ = "NULL"
BUILTIN_OBJ = "BUILTIN"
)

Expand Down Expand Up @@ -54,6 +55,11 @@ func (a *Array) Inspect() string {
return out.String()
}

type Null struct{}

func (n *Null) Type() ObjectType { return NULL_OBJ }
func (n *Null) Inspect() string { return "null" }

type Error struct {
Message string
}
Expand Down

0 comments on commit f93a329

Please sign in to comment.