Partition Array

Split an array into two groups based on a condition.

Code

General
arr.partition { |x| x.even? }

Parameters

Array to partition

Server

More Ruby Snippets