∟Update Object with Object Methods

This section describes the concept of updating object with object methods.

Another concept of Object-Oriented programming is that objects can be updated with object methods.

In procedural programming, function arguments are passed by values. Functions can not easily update any given data objects.

As a hybrid programming language, H built-in classes provide functions to maintain procedural programming behaviors. For example,

# create 2 "integer" objects
i = integer(1);
j = integer(2);

# call "integer" class function add()
# it returns a new "integer" object to "k"
# "i" and "j" are not updated
k = integer.add(i,j); 

# same as k = integer.add(i,j);
k = i + j; 

To support object-oriented programming, H built-in classes provide additional object methods that allows you to update objects. For example,

# create 2 "integer" objects
i = integer(1);
j = integer(2);

# call object method increaseWith() on "i"
# "i" gets updated.
# no new object created
i.increaseWith(j); 

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

 Source Code Packages

 Classes and Objects

►Object Oriented Programming

 What Is Object-Oriented Programming

 Objects Are Created from Classes

 Literal Is Special Form of Object Creation

 Dot (.) Expression to Access Object Members

►Update Object with Object Methods

 Inheritance - Object Attachments

 Encapsulation - Private Members

 References

 Full Version in PDF/ePUB