taroxd 发表于 2015-3-20 20:34
arr_a.inject(arr_b.inject(:+), :+)
或
(arr_a + arr_b).inject(:+)
sum = 0 (arr_a + arr_b).each { |i| sum += i } # sum is what you need
taroxd 发表于 2015-3-20 21:23
sum = 0
(arr_a + arr_b).each { |i| sum += i }
# sum is what you need[/pre]
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |