rearrange builtins
This commit is contained in:
18
builtins/upper.go
Normal file
18
builtins/upper.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package builtins
|
||||
|
||||
import "monkey/object"
|
||||
|
||||
import "strings"
|
||||
|
||||
// Upper ...
|
||||
func Upper(args ...object.Object) object.Object {
|
||||
if len(args) != 1 {
|
||||
return newError("wrong number of arguments. got=%d, want=1",
|
||||
len(args))
|
||||
}
|
||||
|
||||
if str, ok := args[0].(*object.String); ok {
|
||||
return &object.String{Value: strings.ToUpper(str.Value)}
|
||||
}
|
||||
return newError("expected `str` argument to `upper` got=%T", args[0])
|
||||
}
|
||||
Reference in New Issue
Block a user