Product Site

5.4.11.2. []

Returns a substring of the receiving buffer that begins at the n'th character and is of length length. The n must be a positive whole number. If length is omitted, it defaults to 1. If n is greater than the length of the receiving string, a null string is returned.

See also methods substr and subChar.

Example 5.263. MutableBuffer class — [] method
s = .MutableBuffer~new(xrange("a", "z"))
say s[5]        -- "e"
say s[18, 3]    -- "rst"
say s[25,10]    -- "yz"
say s[30]       -- ""