title: Ruby: Who is self inside a block during yielding?
body: <p>Maybe this is a stupid question, but I can't figure it out. I have a &quot;feeling&quot; why <code>main</code> is <code>self</code> during execution of the block. But I don't have a solid explanation for it.</p>
  <p>It seems that the question who is <code>self</code> depends on the context where the block is defined. Is this right?</p>
  <p>Can anyone explain it to me?</p>
  <pre><code>?&gt; class Klass
  ?&gt;   def yld
  ?&gt;     yield
  ?&gt;   end
  &gt;&gt; end
  
  &gt;&gt;
  &gt;&gt; o1 = Klass.new
  &gt;&gt; o2 = Klass.new
  &gt;&gt;
  ?&gt; o1.yld {
  ?&gt;   o2.yld {
  ?&gt;     p self
  ?&gt;   }
  &gt;&gt; }
  main
  </code></pre>