indexOf (Function)
Signature: indexOf(s: string, needle: string) -> Result<int, Error>
Description: Returns the byte index of needle's first occurrence, or Error with 'indexOf: substring not found'.
Parameters
- s (
string): The string to search in - needle (
string): The substring to locate
Returns: Result<int, Error>
Example
match indexOf("foo=bar", "=") {
Success { value } => print(value)
Error { message } => print(message)
}
match indexOf ("foo=bar", "=")
Success value => print value
Error message => print message