⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.13
Server IP:
109.199.105.153
Server:
Linux connect.inboxifs.com 5.15.0-152-generic #162-Ubuntu SMP Wed Jul 23 09:48:42 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.2.29
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
ri
/
3.0.0
/
system
/
Enumerable
/
Edit File: inject-i.ri
U:RDoc::AnyMethod[iI"inject:ETI"Enumerable#inject;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"?Combines all elements of <i>enum</i> by applying a binary ;TI">operation, specified by a block or a symbol that names a ;TI"method or operator.;To:RDoc::Markup::BlankLine o; ; [I"DThe <i>inject</i> and <i>reduce</i> methods are aliases. There ;TI")is no performance benefit to either.;T@o; ; [I"BIf you specify a block, then for each element in <i>enum</i> ;TI"Mthe block is passed an accumulator value (<i>memo</i>) and the element. ;TI"JIf you specify a symbol instead, then each element in the collection ;TI"8will be passed to the named method of <i>memo</i>. ;TI"GIn either case, the result becomes the new value for <i>memo</i>. ;TI"HAt the end of the iteration, the final value of <i>memo</i> is the ;TI"!return value for the method.;T@o; ; [I"OIf you do not explicitly specify an <i>initial</i> value for <i>memo</i>, ;TI"Gthen the first element of collection is used as the initial value ;TI"of <i>memo</i>.;T@o:RDoc::Markup::Verbatim; [I"# Sum some numbers ;TI";(5..10).reduce(:+) #=> 45 ;TI"%# Same using a block and inject ;TI";(5..10).inject { |sum, n| sum + n } #=> 45 ;TI"# Multiply some numbers ;TI"?(5..10).reduce(1, :*) #=> 151200 ;TI"# Same using a block ;TI"?(5..10).inject(1) { |product, n| product * n } #=> 151200 ;TI"# find the longest word ;TI";longest = %w{ cat sheep bear }.inject do |memo, word| ;TI"0 memo.length > word.length ? memo : word ;TI" end ;TI"?longest #=> "sheep";T:@format0: @fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"Penum.inject(initial, sym) -> obj enum.inject(sym) -> obj enum.inject(initial) { |memo, obj| block } -> obj enum.inject { |memo, obj| block } -> obj enum.reduce(initial, sym) -> obj enum.reduce(sym) -> obj enum.reduce(initial) { |memo, obj| block } -> obj enum.reduce { |memo, obj| block } -> obj ;T0[[I"reduce;T@ I"(p1 = v1, p2 = v2);T@2FI"Enumerable;TcRDoc::NormalModule00
Simpan