title: Ruby - instance methods: why can i use getter without self, but setter only with self
body: <p>I have been using Ruby for a while. Now i'm going to dig deeper and find all answers to questions that i have. 
  I hope i will find answer to this one here. So here is my question in code below:</p>
  
  <pre><code>class Game
  
    attr_accessor :in_progress
  
    def initialize
      @in_progress = false
    end
  
    def start!
  
      # debug info                                                                         
      puts self.inspect                        # =&gt; #&lt;Game:0x8f616f4 @in_progress=false&gt;
      puts self.class.instance_methods(false)  # =&gt; [:in_progress, :in_progress=, :start!]
      puts self.instance_variables             # =&gt; [:@in_progress]
      puts self.respond_to?("in_progress=")    # =&gt; true
  
      puts in_progress      # =&gt; true - getter works without self
      # main quesion
      in_progress = true    # Why setter doesn't work without self?
  
      # self.in_progress = true   # this would work and set @in_progress to true becase setter called
      # @in_progress = true       # this would work as well because we set instance variable to true directly
  
    end
  
  end
  
  g = Game.new
  g.start!
  puts g.in_progress # =&gt; false - setter in start! method didn't work
  </code></pre>
  
  <p>What we have here:</p>
  
  <ol>
  <li>Class Game with getter and setter for @in_progress variable</li>
  <li>@in_progress is false by default</li>
  <li>We call start! method and try to change in_progress to true</li>
  <li>Getter for in_progress works well</li>
  <li>Setter works only with self. or with direct access to variable through @in_progress</li>
  </ol>
  
  <p>I read about method lookup in Ruby (Go one step to the right into the receiver's class, and then up the ancestors chain, until you find the method.)
  But i really don't know why i have to use self.in_progress=true to get access to setter method. Especially when getter method works without self.</p>
  
  <p>Thanks in advance!</p>