From: 7stud -- Date: 2009-03-12T20:40:56+09:00 Subject: Re: how to get all attributes in an element Phlip wrote: > Naresh Ramaswamy wrote: > > Next, the attributes come in a Hash, and this has a BUG (!) which will > be FIXED > (!) in the next Ruby versions. It can't preserve the order you inserted > its keys. > Hmm. A bug is when a language doesn't operate as described: ---- p. 46, pickaxe 2: [a hash's] elements are not ordered, so you can not easily use a hash as a stack or a queue. p. 492 The order in which keys and/or values are returned by the various iterators over hash contents may seem arbitrary and will generally not be in insertion order. ---- $ ri Hash ------------------------------------------------------------ Class: Hash A +Hash+ is a collection of key-value pairs. It is similar to an +Array+, except that indexing is done via arbitrary keys of any object type, not an integer index. The order in which you traverse a hash by either key or value may seem arbitrary, and will generally not be in the insertion order. Hashes have a _default value_ that is returned when accessing keys that do not exist in the hash. By default, that value is +nil+. ------------------------------------------------------------------------ Also, in many other languages dictionaries or associative arrays are unordered collections. -- Posted via http://www.ruby-forum.com/.