title: `[]': no implicit conversion of String into Integer (TypeError)
body: <p>I seem to be getting a type error in the following code:</p>
  
  <pre><code>    def can_cast(hand, *spell_cost)
        colored_mana_hand = Array.new
        colored_mana_cost_aggregate = Array.new
        colored_mana_spent = Array.new
        colorless_mana_hand = 0
        colorless_mana_cost_aggregate = 0
  
        hand_array = hand.split("").sort
        total_cost = spell_cost.join.split("").sort   
  
        hand_array.each do |i|
        if hand_array[i].to_i != 0                       
          colorless_mana_hand += hand_array[i].to_i
        else
          colored_mana_hand &lt;&lt; hand_array[i]
        end
      end
  
      total_cost.each do |i|                 
        if total_cost[i].to_i != 0                  
          colorless_mana_cost_aggregate += total_cost[i].to_i
        else
          colored_mana_cost_aggregate &lt;&lt; total_cost[i]
        end
      end
  
  colored_mana_cost_aggregate.each do |i|                                                
    if colored_mana_hand.include?(colored_mana_cost_aggregate[i])
       colored_mana_spent &lt;&lt; colored_mana_cost_aggregate[i]           
  colored_mana_hand.rotate(colored_mana_hand.index(colored_mana_cost_aggregate[i])).shift
    end
  end
  
     colored_mana_spent == colored_mana_cost_aggregate &amp;&amp; (colored_mana_hand.length + colorless_mana_hand) &gt;= colorless_mana_cost_aggregate 
     end
  </code></pre>
  
  <p>It looks like this </p>
  
  <pre><code>   `[]': no implicit conversion of String into Integer (TypeError)
  </code></pre>
  
  <p>Could Anyone help me?</p>
  
  <p>I think I'm using an array as an integer, but I can't see where that might be possible. </p>