Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJeremy Conley
16,657 PointsThe to_s method
Why don't you need to call the to_s method like you called the mark_complete! method?
Jeremy Conley
16,657 PointsWell in this case we also created a to_s method for the program
1 Answer
Brandon Barrette
20,485 PointsSo you can override the default to_s method, which is what happened here. This way, you don't need to format it multiple times elsewhere. Anytime you print the todo_item, it automatically calls the to_s. Here it will be overridden by what you've defined.
Jeremy Lindstrom
6,646 PointsJeremy Lindstrom
6,646 PointsThe mark_complete is one you created for the actual program. Sorry if I am ignorant here, but using to_i, to_f, and to_s, are built in methods in ruby that change the output to to_i will change the output to an integer if it can, to_s will change it to a string if it can, and to_f to change a decimal to a float... This is a great book to go through as well as you go through these lessons. https://pine.fm/LearnToProgram/ it's a ruby book.
Hopefully that's helped a bit? :)