# Array disorder in ruby 1.8.6

**URL:** <https://www.ruby-forum.com/t/array-disorder-in-ruby-1-8-6/133862>\
**Category:** Ruby\
**Created:** [April 4, 2008, 1:57pm UTC](https://www.ruby-forum.com/t/array-disorder-in-ruby-1-8-6/133862 "2008-04-04T13:57:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![moskyt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9a140/32.png) [@moskyt](https://www.ruby-forum.com/u/moskyt)\
**Post date:** [April 4, 2008, 1:57pm UTC](https://www.ruby-forum.com/t/array-disorder-in-ruby-1-8-6/133862/1 "2008-04-04T13:57:55Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![moskyt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9a140/32.png) [@moskyt](https://www.ruby-forum.com/u/moskyt)\
**Post date:** [April 4, 2008, 2:04pm UTC](https://www.ruby-forum.com/t/array-disorder-in-ruby-1-8-6/133862/2 "2008-04-04T14:04:15Z")

</div>

On Fri, Apr 4, 2008 at 1:57 PM, Frantisek H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> runset.each{|k| f.printf(“%-\*s”,ns,k)}  
> 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?

One question: is runset really an Array or a Set? Set doesn’t keep the  
order.

Jano

---

<div class="post-metadata">

**Author:** ![moskyt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9a140/32.png) [@moskyt](https://www.ruby-forum.com/u/moskyt)\
**Post date:** [April 4, 2008, 2:16pm UTC](https://www.ruby-forum.com/t/array-disorder-in-ruby-1-8-6/133862/3 "2008-04-04T14:16:00Z")

</div>

Hi –

On Fri, 4 Apr 2008, Frantisek H. wrote:

> runset.each{|k| f.printf("%-\*s",ns,k)}  
> 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

---

<div class="post-metadata">

**Author:** ![moskyt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9a140/32.png) [@moskyt](https://www.ruby-forum.com/u/moskyt)\
**Post date:** [April 4, 2008, 2:21pm UTC](https://www.ruby-forum.com/t/array-disorder-in-ruby-1-8-6/133862/4 "2008-04-04T14:21:24Z")

</div>

2008/4/4, Frantisek H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> end
> 
> .each iterator just prints the items of the runset array out of order.

What exactly do you mean by “out of order”? What order? What type is  
runset?

> however, if I just evaluate the array anywhere in the method, everything  
> is ok:

What do you mean be “evaluate”?

> 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?

You need to say more about that - otherwise we can’t say much more about  
it.

Cheers

robert
