>From: "Mike Wilson" <wmwilson01 / hotmail.com>
>Reply-To: ruby-talk / ruby-lang.org
>To: ruby-talk / ruby-lang.org (ruby-talk ML)
>Subject: [ruby-talk:11691] Re: How to implement each method
>Date: Tue, 27 Feb 2001 23:48:16 +0900
>
>
>
>
>>From: Max Ischenko <max / malva.com.ua>
>>Reply-To: ruby-talk / ruby-lang.org
>>To: ruby-talk / ruby-lang.org (ruby-talk ML), ruby-talk / netlab.co.jp
>>Subject: [ruby-talk:11690] Re: How to implement each method
>>Date: Tue, 27 Feb 2001 23:40:03 +0900
>>
>>At Tue, 27 Feb 2001 21:46:44 +0900 ts wrote:
>>
>> >>>>>> "M" == Max Ischenko <max / malva.com.ua> writes:
>>
>> >      def each
>> >           @packages.each {|x| yield x}
>> >       end
>>
>>
>>Thanks, it works.
>>Also I changed it to
>>     def each
>>         @packages.each {|key,val|
>>             yield val
>>         }
>>     end
>>
>
>def each
>  @packages.each_value {|val| yield val}
>end
>
>no sense iterating over a key that you don't seem to care about ;)
>

I'm left wondering what you're exactly trying to accomplish.  Maybe you just 
didn't know that you could iterate over the values and so now you don't need 
to define an "each" method to do it?  Maybe just,
@packages.each_value {|val| doSomethingWithVal}
will work for you?

Mike Wilson
Unix Administrator
http://ruby.weblogs.com

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com