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. [email protected]
To: ruby-talk ML [email protected]
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 [email protected] 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