D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Enumerable
/
Filename :
partition-i.ri
back
Copy
U:RDoc::AnyMethod[iI"partition:ETI"Enumerable#partition;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"8With a block given, returns an array of two arrays:;To:RDoc::Markup::BlankLine o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"PThe first having those elements for which the block returns a truthy value.;To;;0; [o; ; [I")The other having all other elements.;T@o; ; [I"Examples:;T@o:RDoc::Markup::Verbatim; [I")p = (1..4).partition {|i| i.even? } ;TI"p # => [[2, 4], [1, 3]] ;TI"-p = ('a'..'d').partition {|c| c < 'c' } ;TI"%p # => [["a", "b"], ["c", "d"]] ;TI"*h = {foo: 0, bar: 1, baz: 2, bat: 3} ;TI":p = h.partition {|key, value| key.start_with?('b') } ;TI"=p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] ;TI"/p = h.partition {|key, value| value < 2 } ;TI"=p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] ;T:@format0o; ; [I"0With no block given, returns an Enumerator.;T@o; ; [I""Related: Enumerable#group_by.;T: @fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"Upartition {|element| ... } -> [true_array, false_array] partition -> enumerator ;T0[ I"();T@/FI"Enumerable;TcRDoc::NormalModule00