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 trial

Ruby Ruby Objects and Classes Variables and Methods Attribute Readers

In the Name class, create an attr_reader for the title instance variable

In the Name class, create an attr_reader for the title instance variable

name.rb
class Name
  def initialize(title, first_name, middle_name, last_name)
    @title = title
    @first_name = first_name
    @middle_name = middle_name
    @last_name = last_name
  end
end

2 Answers

class Name attr_reader :title

def initialize(title, first_name, middle_name, last_name) @title = title @first_name = first_name @midde_name = middle_name @last_name = last_name end end

Thanks! you are so cool!

This is done in the previous video and shown in the teacher's notes for everything but title.