Join Kevin Skoglund for an in-depth discussion in this video Reader/writer methods, part of Ruby: Classes and Modules.
- [Narrator] We've learned about…attributes and instance variables.…Now let's talk about reader and writer methods.…So in our previous example, we had an Animal Class,…and we had make noise, and set noise on it.…We created an instance of the animal,…we were able to call methods like set noise on it.…What if instead of calling the make noise method,…we instead wanted to access that…instance variable noise directly.…To get that value back, why should we…have to call make noise in order to do it?…For example, we might try to do…this, pig dot noise, we can't.…
If we did that we would get back an error,…there's no access to the instance variable…noise from outside the instance.…That's what I'm talking about,…when I'm outside the instance, it's here…when I have the variable and I'm calling a method on it.…We don't have access from outside.…We already talked about it in the last movie,…the instances of a class always…have access to their instance variables.…But that's inside the class,…in other words, the code that's…in the definition has access to it.…
- Defining a custom class
- Working with instances of a class
- Class and instance attributes and methods
- Class inheritance
- Working with dates and times
- Using modules as namespaces and mixins
- Raising and handling exceptions
Skill Level Beginner
2. Class Attributes and Methods
4. Dates and Times
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.