substring (Function)

Signature: substring(s: string, start: int, end: int) -> Result<string, Error>

Description: Extracts s[start, end). Invalid or inverted bounds return Error.

Parameters

  • s (string): The source string
  • start (int): Starting index (inclusive)
  • end (int): Ending index (exclusive)

Returns: Result<string, Error>

Example

substring("hello", 1, 4)  // Success { value: "ell" }
substring ("hello", 1, 4)  // Success { value: "ell" }