From: Morton Goldberg Date: 2006-12-28T14:26:36+09:00 Subject: Re: where does song.name come from? On Dec 27, 2006, at 10:55 PM, chen li wrote: > Hi all, > > On page 49 of Pickaxe 2 are some scripts: > > class Songlist > def with_title(title) > @songs.find{|song| title==song.name} > end > end > > I just wonder where the method "name" comes from and > what its purpose is here. I check for Index on page > 809 and find "name" is mentioned in class Module only, > which returns the name of module mod. Very much earlier in the book (p. 26 in the PDF version) the class Song was defined as follows: class Song def name @name end def artist @artist end def duration @duration end end That's where 'name' comes from. It's a reader method and it's purpose is to return the value of the instance variable Song::@name. It has nothing to do with the method Module::name. Regards, Morton