From: Joao Silva Date: 2012-11-17T01:51:17+09:00 Subject: Accumulate the value of an array if this is repeated Hi All. I have an arrangement with a series of numbers and a string. What I'm trying to make is that when I read an array value compare it to the value of the string and accumulate certain portion of the string if this is repeated. I have the array "numbers": http://dpaste.com/832132/ and I have the string "amounts" http://dpaste.com/832133/ What I'm trying to make is that if I find a number of array "numbers" in the string "amounts", I return the "amount" contained in the string, but if the number of array "numbers" is repeated string "amounts" I returns the sum of the values ​​contained in the string, then place it in another array. Here is the code: ###################################################################### http://dpaste.com/832134/ ######################################################################## for example if you found the number "20222999" contained in the array "numbers" in the string "amounts" which returns the sum of all amounts associated with that number, in this case would be: sum = 205.15 + 110.00 sum = 315.15 and value "sum" is assigned to a new array. Thanks. Thanks. -- Posted via http://www.ruby-forum.com/.