ruby document

Digging Deeper
Hashes, Arrays, Ranges and Sets all include a Ruby module called Enumerable. A module is a sort of code library (I’ll have more to say about modules in Chap-ter 12). In Chapter 4, I used the Comparable module to add comparison methods such as < and > to an array. You may recall that I did this by subclassing the Array class and ‘including’ the Comparable module into the subclass: class Array2 < Array include Comparable end

 

posted @ 2010-09-14 04:04  庚武  Views(231)  Comments(0Edit  收藏  举报