Created
May 27, 2011 09:20
-
-
Save AndrewRadev/994919 to your computer and use it in GitHub Desktop.
ActiveSupport::OrderedHash inconsistency
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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