From 7e9b1609dae0998a4418179f40dc488842c56e5d Mon Sep 17 00:00:00 2001 From: Eli Sadoff <9064062+snood1205@users.noreply.github.com> Date: Tue, 10 Dec 2019 21:25:54 -0500 Subject: [PATCH] Added documentation for integer range sums (#1593) --- enum.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/enum.c b/enum.c index 89148e9326..db5f4d3b6f 100644 --- a/enum.c +++ b/enum.c @@ -4029,6 +4029,10 @@ int_range_sum(VALUE beg, VALUE end, int excl, VALUE init) * { 1 => 10, 2 => 20 }.sum([]) #=> [1, 10, 2, 20] * "a\nb\nc".each_line.lazy.map(&:chomp).sum("") #=> "abc" * + * If the method is applied to an Integer range without a block, + * the sum is not done by iteration, but instead using Gauss's summation + * formula. + * * Enumerable#sum method may not respect method redefinition of "+" * methods such as Integer#+, or "each" methods such as Range#each. */