Skip to content

Modern Array Push

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

Home › Array › Array Container › Push

Push

Adds a value at the end, growing the array as needed.

Syntax

Push( byref v as T )

Notes

  • amortised O(1)

Examples

#import "std/containers"
using containers

dim v as Array( of int32 )

'' Amortised O(1): the storage doubles rather than reallocating per push,
'' which is what the `redim preserve` append idiom gets wrong
for i as int32 = 1 to 5
    v.Push( i * i )
next

print v.Count            '' 5
print v[ 4 ]             '' 25

Library: Array Container
Category: Array
Documented under: Members

Clone this wiki locally