title: ruby uniq with replacement
body: <p>Normal <code>uniq</code>:</p>
  
  <pre><code>[1, 2, 3, 1, 1, 4].uniq =&gt; [1, 2, 3, 4]
  </code></pre>
  
  <p>I want to replace the duplicate with a replacement at where it was.</p>
  
  <p>Is there a method or way to achieve something like this?</p>
  
  <pre><code>[1, 2, 3, 1, 1, 4].uniq_with_replacement(-1) =&gt; [1, 2, 3, -1, -1, 4]
  </code></pre>
  
  <p>Thanks in advance!</p>