H (Hybrid) Language - v0.03, by Dr. Herong Yang
string.set() - Update Character to String
This section describes string.set() function that update a character to a string at a given location.
A "string" data object can be operated like an array of elements. Each element represents each characters in the string.
string.set() function is provided to update the character represented by the element of a given location using the following syntax:
string.set(a, i, x) Parameters: a - A "string" data object. i - An "integer" data object. x - A single character "string" data object. Return: Returns the same "string" data object representing the given string "a" with the character updated to "x" at the location of "i". Location zero, 0, is the first character of the string. Errors: Throws "IndexOutOfBound" error code, if the given integer points to a location outside of the string.
Examples of how to use string.set() function:
string.set("Hello world!", 1, "a"); # Returns "Hallo world!" y = string("Hello world!"); string.set(y, 11, "?"); # Returns "Hallo world?" string.set(y, 12, "#"); # Gets the "IndexOutOfBound" error.
Table of Contents