839 B
839 B
| id | name | category | kind | tokens | sig | tip | order | ns | member |
|---|---|---|---|---|---|---|---|---|---|
| text-starts_with | Text.starts_with | text | namespace-method | Text.starts_with | Text.starts_with(s, prefix) -> bool | Whether a string begins with a given prefix. | 3 | Text | starts_with |
Returns true when s begins with prefix, comparing byte for byte over the length of the prefix. An empty prefix always matches. Use it to route commands ("/help ..."), recognize a tag, or branch on a filename extension without slicing first.
Parameters:
s— the string to testprefix— the leading substring to look for
program Command {
let input: string = "/say hello"
handler Parse phase Update {
if Text.starts_with(input, "/say ") {
let msg = Text.slice(input, 5, Text.length(input))
}
}
}