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

Jonathan Walz
Jonathan Walz
21,429 Points

Getting this error and don't understand why: name.rb:13:in `new': wrong number of arguments (4 for 0) (ArgumentError)

class Name
  attr_reader :title, :first_name, :middle_name, :last_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

name = Name.new("Mr.", "Jon", "James", "Walz")
puts name.title + " " +
  name.first_name + " " +
  name.middle_name + " " +
  name.last_name

2 Answers

Kevin Gravett
Kevin Gravett
11,167 Points

Hey, I think you just need to drop that trailing comma after :last_name in your attr_reader.

Kevin Gravett
Kevin Gravett
11,167 Points

You're welcome -- glad it helped!