dict: implemented length of dict

This commit is contained in:
2024-05-10 09:25:18 +02:00
parent 924051fbcd
commit 4aaffd6c44
2 changed files with 5 additions and 15 deletions
+3
View File
@@ -29,6 +29,9 @@ func evalLength(ctx ExprContext, self *term) (v any, err error) {
} else if IsString(childValue) {
s, _ := childValue.(string)
v = int64(len(s))
} else if IsDict(childValue) {
m, _ := childValue.(map[any]any)
v = int64(len(m))
} else if it, ok := childValue.(Iterator); ok {
if extIt, ok := childValue.(ExtIterator); ok && extIt.HasOperation(countName) {
count, _ := extIt.CallOperation(countName, nil)