rearrange builtins
This commit is contained in:
18
builtins/lower.go
Normal file
18
builtins/lower.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package builtins
|
||||
|
||||
import "monkey/object"
|
||||
|
||||
import "strings"
|
||||
|
||||
// Lower ...
|
||||
func Lower(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.ToLower(str.Value)}
|
||||
}
|
||||
return newError("expected `str` argument to `lower` got=%T", args[0])
|
||||
}
|
||||
Reference in New Issue
Block a user