This may be a dumb question, but I've been unable to determine for
sure from the Pickaxe book:

     When an iterator is applied to an object which is an aggregate
of ordered subcomponents (e.g., a string, an array), does the
formal language definition, or the implementation, guarantee that
the elements are iterated through in a given order (i.e.,
first element 0, then element 1, etc. or possibly the reverse,
from last to first)?  If so, does the programmer have any control
over this, or is it hardwired into the code?

For example, if I just want to sum all the integers in an array,
it doesn't really matter the order in which the elements are
iterated over.  However, if I want to find the last occurence
of the substring "xyz" in a string, it would help alot to be able
to iterate over the string going from the last character to the
first (particular if it is a large string).

The example is probably not all that good, and I really am not
looking for things like "you can do that more efficiently using
regular expressions, or using a particular string method, as
that information, while useful, will not answer the basic
question about how iterators work.

The point is, that I want to know exactly what the rules are
that Ruby uses, so that I can use it intelligently under all
cirmcumstances, and not be surprised by having it act differently
than I had assumed.  I'd also like to be able to have a little
more control over tha order in which an iterator looks at things.

Thanks for any help anyone can offer.

Dennis

---------------------------------------------
|                                           |
|     The way to be happy is to be good     |
|                                           |
---------------------------------------------