5.Attr_reader & Attr_writer, stuck!


#1



https://www.codecademy.com/courses/ruby-beginner-en-zfe3o/0/5?curriculum_id=5059f8619189a5000201fbcb#


uninitialized constant Context::Person::Richard


Replace this line with your code. 
class Person
  attr_reader :name
  attr_writer :job
  def initialize(name, job)
    @name = name
    @job = job
  end
bob = Person.new('Richard','writer')
puts Richard.name
  
  def name
    @name
  end
  
  def job=(new_job)
    @job = new_job
  end
end


Agh! Just gotta finish a few more lessons, but this one is bogging me down. Anyway, this code SHOULD be right, but it won't work for some reason...


#2

@quantumtechnologys

Your code looks a little bit off. This line:

shouldn't be present inside your class (you can't create new instance of the class inside the class!)
Next, you should remove this code:

From the instructions if you've clearly read them, it says you should replace this code by

attr_reader :name 
attr_writer :name

Hope this helped! :wink:


#3

It lets me pass now but it gives me this,

(ruby):7: warning: already initialized constant Richard

(Thanks!)

EDIT: Fixed it! Thanks for the help!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.