HEX
Server: Apache
System: Windows NT MAGNETO-ARM 10.0 build 22000 (Windows 10) AMD64
User: Michel (0)
PHP: 7.4.7
Disabled: NONE
Upload Files
File: C:/Ruby27-x64/share/ri/2.7.0/system/Enumerable/sum-i.ri
U:RDoc::AnyMethod[iI"sum:ETI"Enumerable#sum;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph;	[I"2Returns the sum of elements in an Enumerable.;To:RDoc::Markup::BlankLineo;
;	[I"?If a block is given, the block is applied to each element ;TI"before addition.;T@o;
;	[I"5If <i>enum</i> is empty, it returns <i>init</i>.;T@o;
;	[I"For example:;T@o:RDoc::Markup::Verbatim;	[	I"6{ 1 => 10, 2 => 20 }.sum {|k, v| k * v }  #=> 50
;TI"6(1..10).sum                               #=> 55
;TI"7(1..10).sum {|v| v * 2 }                  #=> 110
;TI"=('a'..'z').sum                            #=> TypeError
;T:@format0o;
;	[I"8This method can be used for non-numeric objects by ;TI"#explicit <i>init</i> argument.;T@o;;	[I"G{ 1 => 10, 2 => 20 }.sum([])                   #=> [1, 10, 2, 20]
;TI">"a\nb\nc".each_line.lazy.map(&:chomp).sum("")  #=> "abc"
;T;
0o;
;	[I"CIf the method is applied to an Integer range without a block, ;TI"Kthe sum is not done by iteration, but instead using Gauss's summation ;TI"
formula.;T@o;
;	[I"FEnumerable#sum method may not respect method redefinition of "+" ;TI"Emethods such as Integer#+, or "each" methods such as Range#each.;T:
@fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"_enum.sum(init=0)                   -> number
enum.sum(init=0) {|e| expr }       -> number
;T0[I"(*args);T@0FI"Enumerable;TcRDoc::NormalModule00