Ruby 2.4 includes several new features such as a #sum method for Enumerable to calculate the sum of elements, faster Array#min and Array#max methods, extracting named captures from regular expression matches, testing if directories and files are empty, a new Integer#digits method to return digits as an array, and simplifying the numeric class hierarchy by removing Fixnum. Additional changes include faster regular expression matching with Regexp#match?, moving Logger configuration to its constructor, and supporting new arguments for float modifiers like ceil, floor, truncate and round.
3. New #sum method for Enumerable
[1, 1, 2, 3, 5, 8, 13, 21].sum # => 54
4. New #sum method for Enumerable
[1, 1, 2, 3, 5, 8, 13, 21].sum # => 54
The #sum method has an optional parameter which defaults to 0.
This value is the starting value of a summation meaning that [].sum is 0.