Attribute Writers
Learn how to set attribute information
Setting attribute information
Imagine that a person not only needs a name but also a password. However, let’s also imagine that, at the time of the creation of a new person
instance, this password is not yet known.
Instead, we want to be able to tell the person
object about its email password later.
We can do this like so:
Press + to interact
class Persondef initialize(name)@name = nameenddef name@nameenddef password=(password)@password = passwordendend
As we can see, the password=
method does nothing else ...