title: Misunderstanding about Object#tap
body: <p>Here is my simple test code:</p>
  
  <pre><code>def test_function
    0.tap do |v|
      v += 10
    end
  end
  
  p test_function
  </code></pre>
  
  <p>Why I get 0 here ? I was waiting to get 10.</p>
  
  <p><strong>Update:</strong></p>
  
  <pre><code>class TestClass
      def initialize
          @v = 0
      end
  
      def inc 
          @v = @v + 1
      end
  end
  
  def test_function
      0.tap do |v|
          v += 10
      end
  end
  
  def test_function_2
      TestClass.new.tap { |obj|
          obj.inc
      }
  end
  
  p test_function
  p test_function_2
  </code></pre>
  
  <blockquote>
    <p>0</p>
    
    <p>TestClass:0x29244f0 @v=1</p>
  </blockquote>