Skip to content

Instantly share code, notes, and snippets.

@RobertFischer
Created July 5, 2012 19:06
Show Gist options
  • Save RobertFischer/3055738 to your computer and use it in GitHub Desktop.
Save RobertFischer/3055738 to your computer and use it in GitHub Desktop.
HashWithIndifferentAccess stores values as strings, becomes string on reverse merge
>> h = HashWithIndifferentAccess.new
=> {}
>> h[:foo] = 'bar'
=> "bar"
>> h[:bar] = 2
=> 2
>> h[:frodo] = 'blah'
=> "blah"
>> h.class
=> HashWithIndifferentAccess
>> h2 = h.reverse_merge(:locals => {})
=> {:locals=>{}, "foo"=>"bar", "frodo"=>"blah", "bar"=>2}
>> h2.class
=> Hash
>> h.class
=> HashWithIndifferentAccess
>> h.inspect
=> "{\"foo\"=>\"bar\", \"frodo\"=>\"blah\", \"bar\"=>2}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment