# How to use partition

**URL:** <https://www.ruby-forum.com/t/how-to-use-partition/171863>\
**Category:** Rails\
**Created:** [July 10, 2009, 11:49am UTC](https://www.ruby-forum.com/t/how-to-use-partition/171863 "2009-07-10T11:49:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dnstevenson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8dc957/32.png) [@dnstevenson](https://www.ruby-forum.com/u/dnstevenson)\
**Post date:** [July 10, 2009, 11:49am UTC](https://www.ruby-forum.com/t/how-to-use-partition/171863/1 "2009-07-10T11:49:46Z")

</div>

Hi Folks,

Real easy one for you probably. I’m just trying to split an array in  
half into 2 separate arrays that I can loop through and have seen the  
Partition method. Can anyone give me an example of how to use this, as I  
don’t quite understand what it means by having a true\_array and a  
false\_array!?

Thanks a lot guys

---

<div class="post-metadata">

**Author:** ![dnstevenson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8dc957/32.png) [@dnstevenson](https://www.ruby-forum.com/u/dnstevenson)\
**Post date:** [July 10, 2009, 12:03pm UTC](https://www.ruby-forum.com/t/how-to-use-partition/171863/2 "2009-07-10T12:03:11Z")

</div>

On Jul 10, 10:49 am, Dave S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi Folks,
> 
> Real easy one for you probably. I’m just trying to split an array in  
> half into 2 separate arrays that I can loop through and have seen the  
> Partition method. Can anyone give me an example of how to use this, as I  
> don’t quite understand what it means by having a true\_array and a  
> false\_array!?

it returns two arrays: the array containing those elements of your  
array for which the block evaluated to something with boolean value  
true (true\_array) and those with boolean value false

Fred
