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

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)

rowend rowend
rowend rowend
2,925 Points

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