Attribute Readers
This lesson explains attribute readers and how they’re related to instance variables.
We'll cover the following
Asking an object for information
Remember that people have the ability to remember their name, and tell it, when asked.
We’ve already implemented the first part of this. Our Person
instance now knows her name, “Ada”
.
Let’s look at the second part. Remember also that methods are either questions or commands. We want to add a method that answers the question, What’s your name?
It’s as simple as this:
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy