From: David Naseby Date: 2003-12-10T11:58:26+09:00 Subject: Re: nuby question re a method >-----Original Message----- >From: vanjac12@yahoo.com [mailto:vanjac12@yahoo.com] > >Question 1. >Is this the same as the following? > >class AddressBook > def each > @persons.each > do |p| > yield p > end > end >end There's some precedence difference between do..end and {}, but semantically they're the same. >defining the method each on the Class AddressBook (an array of hashes; >the addressbook is an array of persons, each person is a hash; >his name, address, etc.) >Question 2. Is my terminology correct? If not, is the meaning >clear enough? Terminology and meaning are pretty much right, but I'd say there's a reasonable difference in Ruby between "defining the method each *ON* the Class" (emphasis mine) and defining the method each in the Class, on the instance. But that's being picky: you knew what you meant, and so did I. (In case that was unclear, you could define the method "on the class addressbook" with def AddressBook.each(); ...; end). If thats still unclear, ignore the whole last 2 paragraphs. David.