Skip to content

Instantly share code, notes, and snippets.

@dchelimsky
Created October 24, 2010 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dchelimsky/642878 to your computer and use it in GitHub Desktop.
Save dchelimsky/642878 to your computer and use it in GitHub Desktop.
hash_with_indifferent_access_double_equals.sh
ruby-1.8.7-p302 > initialized_with_symbol_keys = {:a => 1}.with_indifferent_access
=> {"a"=>1}
ruby-1.8.7-p302 > initialized_with_symbol_keys == {"a" => 1}
=> true
ruby-1.8.7-p302 > initialized_with_symbol_keys[:a] == 1
=> true
ruby-1.8.7-p302 > initialized_with_symbol_keys["a"] == 1
=> true
ruby-1.8.7-p302 > {"a" => 1} == initialized_with_symbol_keys
=> true
ruby-1.8.7-p302 > initialized_with_symbol_keys == {:a => 1}
=> false
ruby-1.8.7-p302 > {:a => 1} == initialized_with_symbol_keys
=> false
ruby-1.8.7-p302 > initialized_with_string_keys = {"a" => 1}.with_indifferent_access
=> {"a"=>1}
ruby-1.8.7-p302 > initialized_with_string_keys == {"a" => 1}
=> true
ruby-1.8.7-p302 > initialized_with_string_keys[:a] == 1
=> true
ruby-1.8.7-p302 > initialized_with_string_keys["a"] == 1
=> true
ruby-1.8.7-p302 > {"a" => 1} == initialized_with_string_keys
=> true
ruby-1.8.7-p302 > initialized_with_string_keys == {:a => 1}
=> false
ruby-1.8.7-p302 > {:a => 1} == initialized_with_string_keys
=> false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment