String module

slice

procedureSource

The part of s that starts at index and holds at most count bytes; empty when index is past the end. Both must not be negative: a negative one fails an assert.

slice :: (s: string, index: s64, count: s64) -> string

Parameters

s: string
index: s64
count: s64

Returns

string
Example↗
assert(slice("hello world", 6, 5) == "world");
assert(slice("abc", 2, 10) == "c"); // cut short, not an error
assert(slice("abc", 5, 1) == "");

See also