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

Benjamin Miller
Benjamin Miller
4,344 Points

cant figure this out

I cant figure out how to do this. So my code is this:

class Name
  attr_reader :first_name, :middle_name, :last_name 

  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

name = Name.new("Mr.", "Jason", "Seifer")
puts name.title + " " +
     name.first_name + " " +
     name.middle_name + " " +
     name.last_name + " " + 

It is giving me this:

name.rb:16: syntax error, unexpected end-of-input                                                              
     name.last_name + " " + 

Help!

2 Answers

rowend rowend
rowend rowend
2,926 Points

I think the plus operator at the end of your code is the problem. Remove it.

So the error message says unexpected "end of input"

What this is saying is "Wait, I saw an end and I wasn't ready"

I won't give you the answer but look through your code and find where your ends are and should they both be in their current location?

Usually what happens is this

Class Here

function here
end

If statement
end

end

(this last one is for the class)