From: "David A. Black" Date: 2008-04-04T21:15:08+09:00 Subject: Re: Array disorder in ruby 1.8.6 Hi -- On Fri, 4 Apr 2008, Frantisek Havluj wrote: > Hello, > > I suppose I found a bug in ruby (or behavior that I am unable to > explain). My version is, exactly, ruby 1.8.6 (2007-03-13 patchlevel 0) > [universal-darwin8.0] > > problem is in this method: > > def plotresults(results,runset) > ... > runset.each{|k| f.printf("%-*s",ns,k)} > ... > end > > .each iterator just prints the items of the runset array out of order. > however, if I just evaluate the array anywhere in the method, everything > is ok: > > def plotresults(results,runset) > runset > ... > runset.each{|k| f.printf("%-*s",ns,k)} > ... > end > > Not much more to say about that. Can anybody explain to me why Ruby > should behave like that? It's impossible to comment without seeing the code where runset is created. David -- Rails training from David A. Black and Ruby Power and Light: ADVANCING WITH RAILS April 14-17 New York City INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin See http://www.rubypal.com for details and updates!