Product SiteDocumentation Site

5.3.6.3. new (Class Method)


>>-new-+----------------+--------------------------------------><
       |    +-,----+    |
       |    V      |    |
       +-(----size-+--)-+

Returns a new empty array. If you specify any size arguments, the size is taken as a hint about how big each dimension should be. The Array class uses this only to allocate the initial array object. For multiple dimension arrays, you can also specify how much space is to be allocated initially for each dimension of the array.
Each size argument must a non-negative whole number. If it is 0, the corresponding dimension is initially empty. The dimensions may also be specified with one single-dimension array of sizes.

Example 5.130. Array class - of method

   a = .array~new()        -- create a new, empty array
   a = .array~new(3,3)     -- create a new 3x3 array
   sizes = .array~of(4,4,4)
   a = .array~new(sizes)   -- create new 4x4x4 array