Join Kevin Skoglund for an in-depth discussion in this video Attributes, part of Ruby Essential Training.
Now that we understand about instances, we need to learn about attributes,…because attributes are how we can differentiate between instances.…For example, if we have an instance of our Animal class that we want to be a…pig, and then another one that we want to be a cow, we have to have some…attribute that will give us a way to tell the difference, and tell which one is…the pig and which one is the cow.…If you think back to our Memo Pad example that I gave you earlier, an…attribute would be the blanks on the form that we're going to fill out with different values.…So what we're really talking about when we say attributes, are values that will…persist inside of an instance, and for that we're going to need a variable, and…a variable that can store those values and keep them around inside the instance.…
It turns out that Ruby has a variable that's especially designed for just that purpose.…We've seen it before back when we were looking at variable scope.…It's the instance variable, and it's prefixed with the @ sign, just a single @…
- Using Ruby in the Interactive Ruby Shell and in standalone scripts
- Learning to write custom code blocks to find, merge, and sort
- Using modules for namespacing or as mix-ins
- Reading from and writing to files
- Creating a full Ruby project from start to finish
Skill Level Beginner
Q: You mention e-texteditor.com as a place to get a Windows "sister" version of TextMate. However, e-texteditor.com looks like a Chinese auto website. Are there any other alternatives?
1. Getting Started with Ruby
2. Ruby Object Types
3. Control Structures
4. Code Blocks
8. Working with Files
9. Ruby Project: Creating the Food Finder
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
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.