Extensions Size

number array:dimensions ( )

Returns the number of elements in the array.  If the array is multi-dimensional, than this value equals the product of all the dimension sizes.

Parameters

None.

Return Values

number Size of array

Example

-- Create array of doubles
local arr = array.new(1000)
assert(arr:size() == 1000)
 
-- Create 3D array of ints
local arr2 = array.new(20, 40, 10, "int")
assert(arr2:size() == 20 * 40 * 10)
 
-- The # operator aliases the size function
assert(arr:size() == #arr)
assert(arr2:size() == #arr2)

Copyright 2010 Justin Aquadro