H (Hybrid) Language - Version 0.02, by Dr. Herong Yang
string.get() - Retrieve Character from String
This section describes string.get() function that retrieves the character from 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.get() function is provided to retrieve the character represented by the element of a given location using the following syntax:
string.get(a, i) Parameters: a - A "string" data object. i - An "integer" data object. Return: Returns a new "string" data object representing the single character from "a" 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.get() function:
string.get("Hello world!", 0); # Returns "H" y = string("Hello world!"); string.get(y, 11); # Returns "!" string.get(y, 12); # Gets the "IndexOutOfBound" error.
Last update: 2017.
Table of Contents