Challenge 2: Custom to_s — Solution class Book attr_accessor :title, :author, :pages def initialize(title, author, pages) @title = title @author = author @pages = pages end def to_s "'#{@title}' by #{@author} (#{@pages} pp.)" end end book = Book.new("The Hobbit", "J.R.R. Tolkien", 310) puts book =begin Output: 'The Hobbit' by J.R.R. Tolkien (310 pp.) Notes: - to_s is defined like any other instance method, but Ruby treats it specially: puts (and string interpolation, and many other places) calls to_s automatically any time it needs to turn an object into a string. - puts book works with no explicit book.to_s call — that's the whole point of overriding to_s instead of writing a separate describe method and remembering to call it everywhere. - Without this override, puts book would have printed Ruby's default, unhelpful representation, something like #. =end