title: Calling Custom Writers Within Instance Methods: Why is self not implicit?
body: <p>I am familiar with the conventional way of using <code>attr_accessors</code> within the <code>initialize</code> method:</p>
  
  <pre><code>class Dog
      attr_accessor :name
  
      def initialize(name)
          @name = name
      end
  end
  
  dog = Dog.new("Denver")
  p dog.name
  
  =&gt; "Denver"
  </code></pre>
  
  <p>I was playing around with custom <code>writers</code> and <code>readers</code>. I was suprised to realize the following:</p>
  
  <ul>
  <li>Within instance methods: you can call upon a <code>reader</code> method without explicitly specifying <code>self</code> because <code>self</code> is implicit. </li>
  <li>Within instance methods: you MUST explicitly call <code>self</code> to call upon a <code>writer</code> method. <code>self</code> IS NOT implicit for <code>attr_writers</code></li>
  </ul>
  
  <p><strong>Example 1</strong> to show that <code>self</code> is implicit when calling <code>attr_reader</code> methods within instance methods:</p>
  
  <pre><code>class Dog
      def name
          @name
      end
  
      def name=(val)
          @name = val
      end
  
      def initialize(name)
          @name = name
      end
  
      def call_name
          # no need to say: p self.name
          p name
      end
  end
  
  dog = Dog.new("Denver")
  dog.call_name
  
  =&gt; "Denver"
  </code></pre>
  
  <p><strong>Example 2</strong> to show that <code>self</code> IS NOT implicit when calling upon <code>attr_writers</code> within instance methods.  In other words: the instance variable is not getting set because I did not prepend the <code>writer</code> method below with <code>self</code>:</p>
  
  <pre><code>class Dog
      def name
          @name
      end
  
      def name=(val)
          @name = val
      end
  
      def initialize(name_val)
          # works as expected with: self.name = name_val
          name = name_val 
      end
  
      def change_name
          # works as expected with: self.name = "foo"
          name = "foo"
      end
  end
  
  dog = Dog.new("Denver")
  p dog.name
  
  dog.change_name
  p dog.name
  
  =&gt; nil
  =&gt; nil
  </code></pre>
  
  <p><strong>Question</strong>: why isn't <code>self</code> implicit within instance methods when calling <code>attr_writers</code>? Why do I have to explicitly specify <code>self</code> for <code>attr_writers</code> within instance methods?</p>