Ruby

29
1237 reads

March 4, 2013

Enumerator with Hash


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.

34
1170 reads

March 4, 2013

Enumerable methods with your MyCollection objects


Enumerable methods with your MyCollection objects

30
1254 reads

March 4, 2013

include Enumerable


Here you could initialize a MyCollection object with an array, which will be stored in the instance variable, @items.

28
1317 reads

March 4, 2013

Simple For Loop


Simple For Loop

37
1271 reads

March 4, 2013

For Loop


For Loop In Ruby

27
1151 reads

March 4, 2013

compare for loops and each iterators with arrays and ranges


This example shows how both for and each can be used to iterate over the values in a range

28
1396 reads

March 4, 2013

For Each


Using For_Each

21
1212 reads

March 4, 2013

Custom Comparison


The easiest way to do this would be to define the nature of the comparison inside a block.

21
1378 reads

March 4, 2013

Enumerator


Hash is such a class.

34
1244 reads

March 4, 2013

Using Enum


The Enumerable module is already included into the Ruby Array class and it provides arrays with a number of useful methods such as include?