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.

as an example

arr=[4,1,3,7]
arr.find { |f| f==someval }
will return the val within arr that matches someval, which doesn't 
really help me because I already have someval

How do I actually return the index in arr to the first match of someval.

so if someval == 3, my block would return 2, for the above example


-- 
Posted via http://www.ruby-forum.com/.