Skip to content

Files

Latest commit

5a68006 · Sep 29, 2024

History

History
executable file
·
22 lines (21 loc) · 909 Bytes

README.md

File metadata and controls

executable file
·
22 lines (21 loc) · 909 Bytes

The this Reference

Every object can access a reference to itself, called the this reference. The this reference can refer implicitly to the instance variable, properties and methods of an object.

Two uses of the this keyword are:

  1. To resolve ambiguity between instance variables and parameters
  2. To pass the current object as a parameter to another method

The first constructor receives three uint parameters which names are identical to the instance variables of the class. I did this to illustrate explicit use of the this reference.

Fig 1 This reference output


The explicit use of the this reference can increase program clarity in some contexts where this is optional.