Read Me - Common Public License V1.0 - Copyright Notice(©)

Examples

Array class - examples

array1=.array~of(1,2,3,4)  /* Loads the array */

/* Alternative way to create and load an array */
array2=.array~new(4)  /* Creates array2, containing 4 items */
do i=1 to 4                   /* Loads the array */
  array2[i]=i
end

You can produce the elements loaded into an array, for example:

Array class - examples

do i=1 to 4
  say array1[i]
end

If you omit any argument values before arguments you supply, the corresponding indexes are skipped in the returned array:

Array class - examples

directions=.array~of("North","South", ,"West")
do i=1 to 4                                  /* Produces: North          */
  say directions[i]                          /*           South          */
                                             /*           The Nil object */
end                                          /*           West           */

Here is an example using the ~~:

Array class - examples

z=.array~of(1,2,3)~~put(4,4)
do i = 1 to z~size
  say z[i]              /* Produces:  1 2 3 4 */
end

Read Me - Common Public License V1.0 - Copyright Notice(©)