Feature #994

Hash-order preservation should be declared a feature; documentation needs to be adapted

Added by JWuttke (Joachim Wuttke) over 3 years ago. Updated about 1 year ago.

[ruby-core:21231]
Status:Closed Start date:01/09/2009
Priority:Normal Due date:
Assignee:matz (Yukihiro Matsumoto) % Done:

100%

Category:core
Target version:1.9.2

Description

I would like to come back to a thread from March 2008 in comp.lang.ruby,
http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/5803482840ed66ca/7af75e86b1975224?hl=enaf75e86b1975224:

For me, hash order preservation is an important advantage of Ruby 1.9; it allows me to generate human-readable YAML output without ugly workarounds.

Matz said, it is now a guaranteed feature of CRuby; but at that time he was still cautious regarding Ruby-the-language. Maybe time has come to establish a consensus and to take a decision. It would give me security for the future of my code base.

Once hash-order preservation is declared a feature, the following text in ri1.9 needs to be adapted:
  "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."

Associated revisions

Revision 25081
Added by marcandre (Marc-Andre Lafortune) over 2 years ago

* hash.c (Hash#each): Fix documentation to reflect insertion order. A patch by Run Paint Run Run [ruby-core:23644] and [ruby-core:21231]

History

Updated by ko1 (Koichi Sasada) over 3 years ago

  • Assignee set to matz (Yukihiro Matsumoto)

Updated by marcandre (Marc-Andre Lafortune) over 2 years ago

  • Category set to core
  • Status changed from Open to Assigned
  • Target version set to 1.9.2

Updated by marcandre (Marc-Andre Lafortune) over 2 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100
Applied in changeset r25081.

Also available in: Atom PDF