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 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!