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

Description: Extracts a substring from start to end index, or returns an error if indices are invalid.

Parameters #

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

Returns: Result<string, Error>

Example #

let sub = substring("hello", 1, 4)
print(sub)  // Prints: Result containing "ell"