Product Site

1.11.6. Array Term

As a convenience, Rexx allows a shortened syntax for creating arrays, called Array term, of the following form:

Except for trailing commas, an Array term returns a newly created array, as if it had been created with the message term rexx:Array~of(…). (An Array term will always return an instance of the Rexx-defined Array class, even if a user-defined class named Array exists.)

Here are some examples:
week = "mon", "tue", "wed", "thu", "fri", "sat", "sun"
say week~items "days"                           -- 7 days

say ("here", "we", "go")~makeString(, " ")      -- here we go

iso639 = .Directory~of(("de", "Deutsch"), ("en", "English"), ("fr", "français"))

do list over .environment, .local
  say list~items                                -- 65
end                                             -- 10

say 0~sendWith("MAX", (2, 3, 5, 7, 11, 13))     -- 13

sparse = ,,,0
say "size" sparse~size"," sparse~items "items"  -- size 4, 1 items

If the array term has trailing commas, the returned array has a bigger size than what .Array~of(…) would have returned:
say (1, , 3, ,)~size .Array~of(1, , 3, ,)~size  -- 5 3
say (,)~size .Array~of(,)~size                  -- 2 0

In a context, where commas already have a different meaning, it may be necessary to put an Array term between brackets. For example:
call func "uno", 2, "tre"      -- no Array term: three parms
call func ("uno", 2, "tre")    -- Array term: one Array as parm

An Array term cannot return an array of size zero or one, although it can return an array with zero or one items (but still of at least size two).
say (,)~items      -- 0
say (,)~size       -- 2