⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.93
Server IP:
65.108.141.171
Server:
Linux server.heloix.com 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
7.4.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
ri
/
2.7.0
/
system
/
Array
/
Edit File: sum-i.ri
U:RDoc::AnyMethod[iI"sum:ETI"Array#sum;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I""Returns the sum of elements. ;TI"?For example, [e1, e2, e3].sum returns init + e1 + e2 + e3.;To:RDoc::Markup::BlankLine o; ; [I"?If a block is given, the block is applied to each element ;TI"before addition.;T@o; ; [I"4If <i>ary</i> is empty, it returns <i>init</i>.;T@o:RDoc::Markup::Verbatim; [I".[].sum #=> 0 ;TI"0[].sum(0.0) #=> 0.0 ;TI".[1, 2, 3].sum #=> 6 ;TI"0[3, 5.5].sum #=> 8.5 ;TI"2[2.5, 3.0].sum(0.0) {|e| e * e } #=> 15.25 ;TI"6[Object.new].sum #=> TypeError ;T:@format0o; ; [I"HThe (arithmetic) mean value of an array can be obtained as follows.;T@o;; [I"&mean = ary.sum(0.0) / ary.length ;T; 0o; ; [I"8This method can be used for non-numeric objects by ;TI"#explicit <i>init</i> argument.;T@o;; [I"2["a", "b", "c"].sum("") #=> "abc" ;TI"8[[1], [[2]], [3]].sum([]) #=> [1, [2], 3] ;T; 0o; ; [I"HHowever, Array#join and Array#flatten is faster than Array#sum for ;TI"*array of strings and array of arrays.;T@o;; [I"2["a", "b", "c"].join #=> "abc" ;TI"8[[1], [[2]], [3]].flatten(1) #=> [1, [2], 3] ;T; 0o; ; [I"IArray#sum method may not respect method redefinition of "+" methods ;TI"such as Integer#+.;T: @fileI"array.c;T:0@omit_headings_from_table_of_contents_below0I"_ary.sum(init=0) -> number ary.sum(init=0) {|e| expr } -> number ;T0[ I"(*args);T@9FI" Array;TcRDoc::NormalClass00
Simpan