5.Attr_reader & Attr_writer, stuck!



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
bob = Person.new('Richard','writer')
puts Richard.name
  def name
  def job=(new_job)
    @job = new_job

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



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:


It lets me pass now but it gives me this,

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


EDIT: Fixed it! Thanks for the help!


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