From: Yohanes Santoso Date: 2002-04-05T11:53:19+09:00 Subject: Re: Question abt. Operation of Iterators Dennis Newbold writes: > 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? Both Array and String fall under the mathematical list category, not mathematical set. So, their iterators travel in a definite order. In the case of #each, the traversal is from the first subcomponent to the last in that order. That is why there is #reverse on both Array and String. YS.