totals = Hash.new(0)

arr = [1, 1, 2, 2, 3, 3, 1, 3]

arr.each do |val|
  totals[val] += 1
end

p totals


--output:--
{1=>3, 2=>2, 3=>3}

-- 
Posted via http://www.ruby-forum.com/.