File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,36 @@ var builtins = map[string]*object.Builtin{
148
148
},
149
149
},
150
150
151
+ "badilisha" : {
152
+ Fn : func (args ... object.Object ) object.Object {
153
+ if len (args ) != 2 {
154
+ return newError ("Samahani, badili inahitaji hoja 2, wewe umeweka %d" , len (args ))
155
+ }
156
+
157
+ value := args [0 ]
158
+ targetType := args [1 ]
159
+
160
+ if targetType .Type () != object .STRING_OBJ {
161
+ return newError ("Aina ya lengo lazima iwe neno" )
162
+ }
163
+
164
+ targetTypeStr := targetType .(* object.String ).Value
165
+
166
+ switch targetTypeStr {
167
+ case "NAMBA" :
168
+ return convertToInteger (value )
169
+ case "DESIMALI" :
170
+ return convertToFloat (value )
171
+ case "NENO" :
172
+ return convertToString (value )
173
+ case "BOOLEAN" :
174
+ return convertToBoolean (value )
175
+ default :
176
+ return newError ("Aina isiyojulikana: %s" , targetTypeStr )
177
+ }
178
+ },
179
+ },
180
+
151
181
// "jumla": {
152
182
// Fn: func(args ...object.Object) object.Object {
153
183
// if len(args) != 1 {
You can’t perform that action at this time.
0 commit comments