Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Ruby Objects and Classes Variables and Methods Methods

Andrew Ackerman
Andrew Ackerman
8,347 Points

My code won't return the full-name method.

I feel like I'm putting too much thought into this, but I'm sure I'm following the exact things I learnt in the video. but I keep getting the same problem. Any help would be greatly appreciated!

name.rb
class Name
  attr_accessor :first_name, :last_name

  def initialize(first_name, last_name)
    @first_name = first_name
    @last_name = last_name
  end

  def full_name
    @first_name + "" + @last_name
  end
end

name = Name.new("Andrew", "Ackerman")
puts name.full_name

1 Answer

Ben Reynolds
Ben Reynolds
35,170 Points

In the full_name function, you need to put a space between first name and last name.

Andrew Ackerman
Andrew Ackerman
8,347 Points

Oh my gosh. I've been staring at it for so long with no clue. Thanks for that!