From: "David A. Black" Date: 2005-09-28T02:53:11+09:00 Subject: Re: Class and Iterator Design Question Hi -- On Wed, 28 Sep 2005, Jim Freeze wrote: > This may be a silly design question, but I always balk at > the right answer when I am confronted with it. > > I have a class that manages a list and users need to iterate over that list. > The way I see it, I have to basic alternatives: > > # Give user access to the array and let them iterate over Array > class Pea > attr_reader :pods > end > Pea.new.pods.each { |pod| ..do stuff.. } > > or > > # Provide a custom iterator > class Pea > def each_pod Why not just call that #each? (And, as others have said, possibly include Enumerable, though only if you need the other Enumerable stuff). David -- David A. Black dblack@wobblini.net