title: Ruby 'tap' method - inside assignment
body: <p>Recently I discovered that <code>tap</code> can be used in order to "drily" assign values to new variables; for example, for creating and filling an array, like this:</p>
  
  <pre><code>array = [].tap { |ary| ary &lt;&lt; 5 if something }
  </code></pre>
  
  <p>This code will push <code>5</code> into <code>array</code> if <code>something</code> is truthy; otherwise, <code>array</code> will remain empty.</p>
  
  <p>But I don't understand why after executing this code:</p>
  
  <pre><code>array = [].tap { |ary| ary += [5] if something }
  </code></pre>
  
  <p><code>array</code> remains empty. Can anyone help me?</p>