19 lines
406 B
Go
19 lines
406 B
Go
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])
|
|
}
|