title: function that returns the number of letters that repeat in a string
body: <p>Trying to make a function that counts the number of letters that appear more than once anywhere in a string (not necessarily together, and not the the number of times they repeat). This is what I have:</p>
  
  <pre><code>def num_repeats(string)
  
      repeat = []
  
      i1 = 0
      i2 = 1
      while i1 &lt; string.length 
          while  i2 &lt; string.length
              if (string[i1] == string[i2]) &amp;&amp; (!repeat.include? string[i1]) 
                  repeat &lt;&lt; string[i1]
              end
              i2 +=1
          end 
          i1+=1
      end
  
      return repeat.length
  end
  
  puts(num_repeats('sldhelanlaskjkajksda'))
  </code></pre>
  
  <p>For some reason, it only pushes the first letter of the string if that first letter has been used in the rest of the string, but after that, it seems like the method stops looping through the rest of the string.</p>
  
  <p>I'd like to know first why the current code is not working and if there is a way to fix it, and I also welcome other better solutions.</p>