Iterators: Removed NewAnyIterator(), added NewIterator()

This commit is contained in:
2026-04-24 06:26:00 +02:00
parent c39ee7cec0
commit 20d8236325
6 changed files with 52 additions and 35 deletions
+27
View File
@@ -0,0 +1,27 @@
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
// All rights reserved.
// iter-factory.go
package expr
func NewIterator(value any) (it Iterator, err error) {
if value == nil {
return NewArrayIterator([]any{}), nil
}
switch v := value.(type) {
case *ListType:
it = NewListIterator(v, nil)
case *DictType:
it, err = NewDictIterator(v, nil)
case []any:
it = NewArrayIterator(v)
case *ListIterator:
it = v
case *DictIterator:
it = v
default:
it = NewArrayIterator([]any{value})
}
return
}