From: 7stud -- Date: 2009-05-03T06:13:30+09:00 Subject: n00b ? re: CGI Hash and arrays 7stud -- wrote: > > params.each do |key, val| > num_str = val[0] > num = num_str.to_i > total += num > end > Once you understand that, you can make it briefer: params.each do |key, val| total += val[0].to_i end ...however if it's possible that the arrays can contain more than one string, then you need to loop over each array too. As per Rob Biedenharn's solution: params = { "conf_mod"=>["20", "10"], "conf_impact"=>["10"], "avail_impact"=>["5", "10"], #<--xtra strings "integrity_impact"=>["5"], "authorization"=>["5", "10"], "integrity_mod"=>["5"] } total = 0 params.each do |key, val| val.each do |str| total += str.to_i end end puts total --output:-- 80 -- Posted via http://www.ruby-forum.com/.