Skip to content

Instantly share code, notes, and snippets.

@AndrewRadev
Created May 27, 2011 09:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewRadev/994919 to your computer and use it in GitHub Desktop.
Save AndrewRadev/994919 to your computer and use it in GitHub Desktop.
ActiveSupport::OrderedHash inconsistency
# Ruby 1.8.7
# ActiveSupport 3.0.7
require 'rubygems'
require 'active_support/ordered_hash'
require 'pp'
ordered = ActiveSupport::OrderedHash.new
standard = Hash.new
ordered[:one] = standard[:one] = 1
puts
puts ">> Standard Hash: "
puts
standard.each { |*v| puts v.inspect }
standard.each_pair { |*v| puts v.inspect }
puts
puts ">> Ordered Hash: "
puts
ordered.each { |*v| puts v.inspect }
ordered.each_pair { |*v| puts v.inspect }
#
# >> Standard Hash:
#
# [[:one, 1]]
# [:one, 1]
#
# >> Ordered Hash:
#
# [[:one, 1]]
# [[:one, 1]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment