Ruby Ruby Objects and Classes Variables and Methods Variables and Methods

Francisco Nolla
Francisco Nolla
15,085 Points

In the initialize method of the Name class, set an instance variable called @title to the title argument.

when i type name.title it says that part 1 is no longer true

class.rb
class Name
  def first_name
    "Metal"
  end

  def initialize(title)
    @title = title
  end

  def last_name
    "Robot"
  end
end

name = name.new("mr.")
name.title

1 Answer

Jacob Herrington
Jacob Herrington
15,835 Points

Hi Francisco, you've made a really simple mistake. Don't worry though, even as a professional Ruby-on-Rails developer I do this all the time.

When you are referring to a class you usually start with an uppercase letter - the same way you did when you defined the class.

class Name   # here is where you are using an uppercase letter
...
end

When you initialize the new object from the class you should make sure to use that uppercase letter.

name = name.new("mr.")

Should be:

name = Name.new("mr.")