Join Kevin Skoglund for an in-depth discussion in this video Instances, part of Ruby: Classes and Modules.
- [Instructor] In the last movie…we learned how to define a class.…But that's only half of what we need.…We also need to be able to create an instance of it.…An instance is a single object…that's created from a class definition.…Get used to that name because we're going to be using…the word instance a lot.…Instead of talking about objects,…we're going to be talking about instances…that we create from a class.…Now an instance is an object.…But we're going to use the word instance most of the time.…We've already seen how to create…instances of classes before.…For example if we just have a string, pasta,…that's an instance of the class string.…
You can also call the new method on a class…to create a new instance of that class.…These work the same way.…But when I call string.new,…it just creates an empty string.…The same is true if a call array.new.…Or hash.new.…It just creates a new instance of that class.…So we can do the same thing with our classes.…If we have our person class,…we can create a new instance of it using person.new.…
- 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.