module Enumerable

instance methods

Enumerable#nest &compare

nest is an inverse for Array#flatten. (Well, actually only a right inverse since flatten is not injective.) You give it a proc that calculates the depth of each item, and it returns a nesting of arrays in which each item has the desired depth. It can be used to parse strings with Python-like indentation syntax, but it isn't limited to strings.

The main improvement in this version is that the compare block can return a lower value for an element after the first, with the expected effect. See the first example at the end of the source file.


Enumerable tools 1.6

The current version of this software can be found at .


This software is distributed under the Ruby license. See


Joel VanderWerf,