... a particular test.
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].reject(isEven);
//-> [1, 3, 5, 7, 9]
Using Enumerable#partition
When you need to separate a collection into two groups, use Enumerable#partition.It
returns ... and the sec-
ond an arr
ay of all items that failed the test.
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].partition(isEven);
//-> [ [2, 4, 6, 8, 10], [1, 3, 5, 7, 9] ]
Sorting Collect...
Ngày tải lên :
03/07/2014, 01:20