array.set() - Update Element of Array

This section describes array.set() function that update a character to a string at a given location.

array.set() function is provided to update the array element of a given location using the following syntax:

array.set(a, i, x)

Parameters:
   a - A "array" data object.
   i - A "integer" data object.
   x - A data object.

Return: 
   Returns the same "array" data object reference by "a" 
   with element at location of "i" updated to "x".
   
Errors:
   Throws "IndexOutOfBound" error code, if the given integer 
   points to a location outside of the range of array element index.
   

Examples of how to use array.set() function:

array.set([1, "Two", 3], 1, "2"); # Returns array of [1, "2", 3]

y = array([1, "Two", 3]); 
array.set(y, 1, "2"); # Returns array of [1, "2", 3]

array.set(y, -1, "?"); # Gets the "NegativeIndex" error.

Last update: 2017.

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

 "real" Data Type

"array" Data Type

 What Is "array" Data Type

 "array" Literals

 Constructor Function: array()

 array.get() - Retrieve Element from Array

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

array.set() - Update Element of Array

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

 "array" "add" Operation

 array.subArray() - Sub-Array Function

 Source Code Packages

 Classes and Objects

 Object Oriented Programming

 Inheritance - Object Attachments

 Encapsulation - Private Members

 References

 PDF Printing Version