Skip to content

Commit a77b075

Browse files
authored
Merge pull request #98 from NuruProgramming/fh/improve-type-casting
improve type casting builting
2 parents f520183 + f1d4830 commit a77b075

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

evaluator/builtins.go

+18
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,24 @@ var builtins = map[string]*object.Builtin{
177177
}
178178
},
179179
},
180+
"namba": {
181+
Fn: func(args ...object.Object) object.Object {
182+
if len(args) != 1 {
183+
return newError("Samahani, namba inahitaji hoja 1, wewe umeweka %d", len(args))
184+
}
185+
value := args[0]
186+
return convertToInteger(value)
187+
},
188+
},
189+
"tungo": {
190+
Fn: func(args ...object.Object) object.Object {
191+
if len(args) != 1 {
192+
return newError("Samahani, tungo inahitaji hoja 1, wewe umeweka %d", len(args))
193+
}
194+
value := args[0]
195+
return convertToString(value)
196+
},
197+
},
180198

181199
// "jumla": {
182200
// Fn: func(args ...object.Object) object.Object {

0 commit comments

Comments
 (0)