class

ActiveSupport::OrderedHash

v7.1.3.4 - Show latest stable - Superclass: Array

DEPRECATED: +ActiveSupport::OrderedHash+ implements a hash that preserves insertion order.

oh = ActiveSupport::OrderedHash.new
oh[:a] = 1
oh[:b] = 2
oh.keys # => [:a, :b], this order is guaranteed

Also, maps the omap feature for YAML files (See yaml.org/type/omap.html) to support ordered items when loading from YAML.

+ActiveSupport::OrderedHash+ is namespaced to prevent conflicts with other implementations.

Files

  • activesupport/lib/active_support/ordered_hash.rb

1Note

Superclass of OrderedHash

mcmire ยท Apr 8, 20096 thanks

Note that in Rails 2.3, OrderedHash changed from being a subclass of Array to a subclass of Hash. This is contrary to what the documentation says above.