On Wed, 2006-03-15 at 13:08 +0900, Tod McIntyre wrote:
> This is quite embarassing because I Don't consider myself a poor 
> programmer, but I just started looking at ruby the other day.
> 
> Blocks seem to be a good way to iterate through something to search for 
> an entry for instance.  It's easy to return the object that meets 
> certain criteria using blocks but I'm finding it hard to return the 
> index of that particular object in, say, an array.

Check out this thread:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/178495

(The upshot is that in CVS, 1.9 now allows a block to #index to specify
what is to be found).

In the meantime, the current #index should do the job for most cases
(e.g. the example you showed):

	a = [:a,:b,:c,:d,:e]
	# => [:a, :b, :c, :d, :e]

	a.index(:a)
	# => 0

	a.index(:e)
	# => 4

-- 
Ross Bamford - rosco / roscopeco.REMOVE.co.uk