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

 About This Book

 Introduction of H Language

 Syntax

 Data Types

 Variables

 Expressions

 Statements

 "boolean" Data Type

 "integer" Data Type

"string" Data Type

 What Is "string" Data Type

 "string" Literals

 Escape Sequences in "string" Literals

 Escape Sequences for Non-Printable ASCII Characters

 Escape Sequences for Unicode Characters

 String Literals with Line Breaks

 String Literals Continuing on Next Lines

 Expression Interpolation in String Literals

 String Literals with No Escape Sequences

 Constructor Function: string()

 string.get() - Retrieve Character from String

 x[i] - Array Element Format for string.get()

string.set() - Update Character to String

 x[i] - Array Element Format for string.set()

 "string" "add" Operation

 "string" "subtraction" Operation

 "string" "multiplication" Operation

 "string" "division" Operation

 "string" "modulo" Operation

 string.length() Function

 "real" Data Type

 "array" Data Type

 Source Code Packages

 Classes and Objects

 Object Oriented Programming

 Inheritance - Object Attachments

 Encapsulation - Private Members

 References

 Full Version in PDF/ePUB