7stud -- wrote in post #1089991:
>
> And here is how to correct the problem:
>
> class Dog
>   def title=(val)
>     @title = val.capitalize
>   end
>
>   def do_stuff
>     self.title = "mr."
>     title + " Dog"
>   end
> end
>
> puts Dog.new.do_stuff
>
>


That should be:

class Dog
  def title=(val)
    @title = val.capitalize
  end

  #MISSING getter **********
  def title
    @title
  end

  def do_stuff
    self.title = "mr."
    title + " Dog"
  end
end

puts Dog.new.do_stuff

--output:--
Mr. Dog

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to