D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Array
/
Filename :
combination-i.ri
back
Copy
U:RDoc::AnyMethod[iI"combination:ETI"Array#combination;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [ I"!When a block and a positive ;TI"a{integer-convertible object}[rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects] ;TI"8argument +count+ (<tt>0 < count <= self.size</tt>) ;TI"Qare given, calls the block with each combination of +self+ of size +count+; ;TI"returns +self+:;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [I"Ja = %w[a b c] # => ["a", "b", "c"] ;TI"Ja.combination(2) {|combination| p combination } # => ["a", "b", "c"] ;T:@format0o; ; [I"Output:;T@o;; [I"["a", "b"] ;TI"["a", "c"] ;TI"["b", "c"] ;T; 0o; ; [I"=The order of the yielded combinations is not guaranteed.;T@o; ; [I"GWhen +count+ is zero, calls the block once with a new empty array:;T@o;; [I"5a.combination(0) {|combination| p combination } ;TI"6[].combination(0) {|combination| p combination } ;T; 0o; ; [I"Output:;T@o;; [I"[] ;TI"[] ;T; 0o; ; [I"RWhen +count+ is negative or larger than +self.size+ and +self+ is non-empty, ;TI"does not call the block:;T@o;; [I"Ra.combination(-1) {|combination| fail 'Cannot happen' } # => ["a", "b", "c"] ;TI"Ra.combination(4) {|combination| fail 'Cannot happen' } # => ["a", "b", "c"] ;T; 0o; ; [I"3With no block given, returns a new Enumerator.;T@o; ; [I"!Related: Array#permutation; ;TI"Lsee also {Methods for Iterating}[rdoc-ref:Array@Methods+for+Iterating].;T: @fileI"array.c;T:0@omit_headings_from_table_of_contents_below0I"Vcombination(count) {|element| ... } -> self combination(count) -> new_enumerator ;T0[ I" (p1);T@?FI" Array;TcRDoc::NormalClass00