Extensions New

array array.new ( number i1i2, ... in [, string type] )

Creates and returns a new static array object of one or more dimensions.  If no type is specified, then the element type of the array will be a double.

Memory for the array is pre-allocated immediately, and is equal to the product of all the dimension sizes and the size of the storage type.  Elements stored in the static array will never be collected by the garbage collector, until the entire object is collected.

The acceptable storage types are: char, byte, short, int, long, float, and double.  Storage types cannot be changed after the array is created.

Parameters

in One or more dimension sizes 
type Optional.  The storage type of the elements

Return Values

array A new static array object

Error Conditions

If there is not enough available memory in the system to satisfy the reqested size, this function will signal an error.

Example

-- Create an array of doubles
local arr = array.new(1000)
 
-- Create an array of ints
local arr2 = array.new(500, "int")
 
-- Create a 3D array of bytes
local arr3 = array.new(10, 20, 5, "byte")

Copyright 2010 Justin Aquadro