Skip to content

Commit 4512e97

Browse files
committed
4.6 Hello World
Add one last built-in function: puts. puts prints the given arguments on new lines to STDOUT.
1 parent 3386b53 commit 4512e97

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

evaluator/builtins.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package evaluator
22

33
import (
4+
"fmt"
5+
46
"github.com/cedrickchee/hou/object"
57
)
68

@@ -109,4 +111,12 @@ var builtins = map[string]*object.Builtin{
109111
return &object.Array{Elements: newElements}
110112
},
111113
},
114+
"puts": &object.Builtin{
115+
Fn: func(args ...object.Object) object.Object {
116+
for _, arg := range args {
117+
fmt.Println(arg.Inspect())
118+
}
119+
return NULL
120+
},
121+
},
112122
}

0 commit comments

Comments
 (0)