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

subWords


>>-subWords(--+---+-+---------+-)-------------------------------------><
              +-n-+ +-,length-+

Returns an array containing all words within the substring of the receiving string that starts at the [n] th word and is up to [length] blank-delimited words. The [n] must be a positive whole number. If you omit [n] , it defaults to 1. If you omit [length] , it defaults to the number of remaining words in the receiving string. The strings in the returned array never have leading or trailing whitespace.

String class - subWords method

"Now is the  time"~subWords         ->    .array~of("Now", "is", "the", "time")
"Now is the  time"~subWords(2,2)    ->    .array~of("is", "the")
"Now is the  time"~subWords(3)      ->    .array~of("the", "time")
"Now is the  time"~subWords(5)      ->    .array~new(0)

The subWords method is useful for iterating over the individual words in a string.

String class - subWords method

    do word over source~subWords    -- extract all of the words to loop over
       say word
    end

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