aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-05-20 17:10:53 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-05-20 17:10:53 +0200
commit3f96b24e96d759bf154520c0181bba0f42a55122 (patch)
treefdf2cc676d630ac562c35eb7353601a10f889c26
parent4e2925ef695a31bca474654705371ff91c4dd7cc (diff)
fmt
-rw-r--r--evaluator/builtins.go31
1 files changed, 16 insertions, 15 deletions
diff --git a/evaluator/builtins.go b/evaluator/builtins.go
index 4240291..2f85223 100644
--- a/evaluator/builtins.go
+++ b/evaluator/builtins.go
@@ -7,22 +7,23 @@ import (
)
var builtins = map[string]*object.Builtin{
- "len": &object.Builtin{Fn: func(args ...object.Object) object.Object {
- if len(args) != 1 {
- return newError("wrong number of arguments. got=%d, want=1",
- len(args))
- }
+ "len": &object.Builtin{
+ Fn: func(args ...object.Object) object.Object {
+ if len(args) != 1 {
+ return newError("wrong number of arguments. got=%d, want=1",
+ len(args))
+ }
- switch arg := args[0].(type) {
- case *object.Array:
- return &object.Integer{Value: int64(len(arg.Elements))}
- case *object.String:
- return &object.Integer{Value: int64(len(arg.Value))}
- default:
- return newError("argument to `len` not supported, got %s",
- args[0].Type())
- }
- },
+ switch arg := args[0].(type) {
+ case *object.Array:
+ return &object.Integer{Value: int64(len(arg.Elements))}
+ case *object.String:
+ return &object.Integer{Value: int64(len(arg.Value))}
+ default:
+ return newError("argument to `len` not supported, got %s",
+ args[0].Type())
+ }
+ },
},
"puts": &object.Builtin{
Fn: func(args ...object.Object) object.Object {