# Re: Passing a method call into a method

**URL:** <https://www.ruby-forum.com/t/re-passing-a-method-call-into-a-method/148760>\
**Category:** Ruby\
**Created:** [September 16, 2008, 10:11pm UTC](https://www.ruby-forum.com/t/re-passing-a-method-call-into-a-method/148760 "2008-09-16T22:11:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![glenn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/4bbf92/32.png) [@glenn](https://www.ruby-forum.com/u/glenn)\
**Post date:** [September 16, 2008, 10:11pm UTC](https://www.ruby-forum.com/t/re-passing-a-method-call-into-a-method/148760/1 "2008-09-16T22:11:46Z")

</div>

Hi,

Thanks for the help with my question.Â All three solutions are great.

Sorry I wasn’t more clear describing the problem.Â I’ll try to be more  
clear when I ask another question in the future.

I have to admit that I don’t think I understand the method below.Â I  
tried it out and see that it works, but don’t necessarily see how it  
works yet.Â I will look at it some more.

Thanks again,

Glenn

----- Original Message ----  
From: William J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: ruby-talk ML [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Sunday, September 14, 2008 4:02:54 PM  
Subject: Re: Passing a method call into a method

On Sep 14, 8:18 am, Glenn [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Â Â if self.empty?  
> Â Â Â ‘The array is empty.’  
> Â Â else  
> Â Â Â h = {}  
> Â Â Â self.each\_with\_index { |e, i| h.include?(e.to\_f) ? h[e.to\_f] \<\< i : h[e.to\_f] = [i] }  
> Â Â Â h  
> Â Â end  
> Â end

class Array  
Â def hash\_of\_indexes  
Â Â h = {}  
Â Â each\_with\_index{ |e,i|  
Â Â Â e = e.to\_f  
Â Â Â h[e] = Array( h[e] ) \<\< i }  
Â Â h  
Â end  
end
