Use your MyCollection class to process arrays such as the keys or values of Hashes. Currently the min and max methods adopt the default behaviour of performing comparisons based on numerical values.
Use your MyCollection class to process arrays such as the keys or values of Hashes. Currently the min and max methods adopt the default behaviour of performing comparisons based on numerical values.
Here you could initialize a MyCollection object with an array, which will be stored in the instance variable, @items.
This example shows how both for and each can be used to iterate over the values in a range
The easiest way to do this would be to define the nature of the comparison inside a block.
The Enumerable module is already included into the Ruby Array class and it provides arrays with a number of useful methods such as include?