Getter and Setters
Learn how to read and write properties using getters and setters.
We'll cover the following...
Introduction
Getters and setters are special methods that provide read and write access to an object’s properties. Recall how we were able to retrieve and set the values of instance variables using the dot operator (.
). Each instance variable has an implicit getter and setter which we have been using up until now. In this lesson, we will explore the getter and setter methods.
Getters
Getters are functions that are used to retrieve the values of an object’s properties and are defined using the get
keyword. ...