Iterator: new function Count()
This commit is contained in:
+7
-7
@@ -30,16 +30,16 @@ func evalLength(ctx ExprContext, opTerm *term) (v any, err error) {
|
||||
s, _ := childValue.(string)
|
||||
v = int64(len(s))
|
||||
} else if IsDict(childValue) {
|
||||
// m, _ := childValue.(map[any]any)
|
||||
m, _ := childValue.(*DictType)
|
||||
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)
|
||||
v, _ = ToGoInt(count, "")
|
||||
} else {
|
||||
v = int64(it.Index() + 1)
|
||||
}
|
||||
v = int64(it.Count())
|
||||
// if extIt, ok := childValue.(ExtIterator); ok && extIt.HasOperation(CountName) {
|
||||
// count, _ := extIt.CallOperation(CountName, nil)
|
||||
// v, _ = ToGoInt(count, "")
|
||||
// } else {
|
||||
// v = int64(it.Index() + 1)
|
||||
// }
|
||||
} else {
|
||||
err = opTerm.errIncompatibleType(childValue)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user