diff options
author | Eli Sadoff <9064062+snood1205@users.noreply.github.com> | 2019-12-10 21:25:54 -0500 |
---|---|---|
committer | Kenta Murata <mrkn@users.noreply.github.com> | 2019-12-11 11:25:54 +0900 |
commit | 7e9b1609dae0998a4418179f40dc488842c56e5d (patch) | |
tree | e9c1953a47fa6b47fd2d3f380469ae3f68d3dcd2 /enum.c | |
parent | 86e2c013d7ade7c93077d599e155aae0f3b632e8 (diff) | |
download | ruby-7e9b1609dae0998a4418179f40dc488842c56e5d.tar.gz |
Added documentation for integer range sums (#1593)
Diffstat (limited to 'enum.c')
-rw-r--r-- | enum.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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. */ |