From: Frederick Cheung Date: 2008-08-19T18:44:27+09:00 Subject: Re: Array API On 19 Aug 2008, at 10:06, Tushar Gandhi wrote: > Hi, > I am going through the ruby Array API. In the API , there is > staetment > > Included Modules > Enumerable > > Is this means that we are inheriting the enumerable class to array? > Not inheriting. That means the Enumerable module is mixed in to Array (and similarly to Hash and other collections) > Also there is sort_by method for the enumerable object, but I am > able to > use this method for array of object. > > I have this type of array of Object:- > [#nil, "lastname"=>"aikhe", > "firstname"=>"mita", "id"=>"1"}>,# @attributes={"email3"=>nil, "lastname"=>"aikhe", "firstname"=>"na", > "id"=>"2"}>] > > How it is possible that we are able to use enumerable sort_by method > for > an array of object? > Because that's what including a module does: it adds the methods defined in the module to the class. Fred