Earlier quoted context omitted.
In PHP array_sum([1, 2, 3, 4, 5]);
The GP's point is that Ruby doesn't require a built-in method that specifically sums an array to still get a clean, terse operation. You can use #inject to apply an arbitrary operation to (operator, last result, current element) and arrive at a result. For example, given a list of numbers, you can generate a bitwise OR mask easily: [1,2,3,4,5].inject(:|) What this does is iterate over the list and apply ($last_result…
array_reduce(array(1,2,3,4,5), create_function('$v, $e', 'return $v | $e;'), 0);