Skip to content

Modern Array GetIterator

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Array › Array Container › GetIterator

GetIterator

Returns an iterator over the elements, for stepping through them by hand.

Syntax

GetIterator( ) as ArrayIterator( of T )

Examples

#import "std/containers"
using containers

dim v as Array( of int32 )
v.Push( 1 ) : v.Push( 2 ) : v.Push( 3 )

'' The iterator protocol -- IsValid / Value / MoveNext -- which is what
'' `for each` is built on
dim it as ArrayIterator( of int32 ) = v.GetIterator( )
while it.IsValid( )
    print it.Value( )
    it.MoveNext( )
wend

'' Value( ) returns BYREF, so an iterator can modify in place
dim jt as ArrayIterator( of int32 ) = v.GetIterator( )
jt.Value( ) = 99
print v[ 0 ]             '' 99

Library: Array Container
Category: Array
Documented under: Members

Clone this wiki locally