Join Kevin Skoglund for an in-depth discussion in this video Solution: To-do list, part of Ruby: Classes and Modules.
(technology music)…- [Instructor] Hopefully, you were able…to complete the To Do List Challenge.…In this movie, I'm going to show you the solution…that I came up with.…So you should have already had the…to-do list project sort of skeleton…in place, including this init.rb file.…What your assignment was, was to write…this to-do list on rb file.…That's our class.…It's a fairly small and simple class,…but it does take some thinking…about how things are going to go together,…how we can put the different pieces together.…So we've got our class definition, ToDoList,…it's going to include enumerable.…
Remember include is the word that we're…going to use before we have a mix-in.…So this is going to take all the functionality…of enumerable, and just drop it into our class,…right in this spot.…Now I've got an attribute accessor for items.…I don't have to have that.…That's not strictly necessary, but I wanted…to be able to call todolist.items,…or have a to-do list and call items equal,…and be able to assign new items to it.…It's up to you.…
- 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.