Hi --

On Wed, 28 Sep 2005, Jim Freeze wrote:

> Wow, thanks for all the responses.
>
> First, duh, yeah, I got it backwards (pod and peas should be reversed.)
>
> So, from what I have read, we have:
>
>  1. Pod.new.each { |pea| ... }
>  2. Pod.new.peas.each { |pea| ... }
>
> #2 compromises the OO integrity. I understand that, but
> I guess I am bugged by #1 where Pod.new.each yields a 'pea'.
> If I see a Pod.each, I kind of expect to get a 'pod' back, not
> a pea. That is the reason I did #each_pod.
>
> Any comments on this?

I think if you're using pod/peas as a container/elements example, then
you should accept that the container contains the elements :-)

   pod.each {|pea| ... }

has enough pod/pea semantics to make it clear.  In fact, this:

   pod.each_pea {|pea| ... }

seems a bit redundant to me.  (Unless there's something else that a
pod might iterate over, similar to String#each vs. String#each_byte.
Of course, lots of people wish that String#each did what
String#each_byte does :-)


David

-- 
David A. Black
dblack / wobblini.net