Consider:

 irb(main):001:0> a=1 => 1
 irb(main):002:0> b=1 => 1
 irb(main):003:0> c={} => {}
 irb(main):004:0> c[a]=1 => 1
 irb(main):005:0> c[b]=1 => 1
 irb(main):006:0> c.inspect => "{1=>1}"

and

 irb(main):007:0> a="K" => "K"
 irb(main):008:0> b="K" => "K"
 irb(main):009:0> c={} => {}
 irb(main):010:0> c[a]=1 => 1
 irb(main):011:0> c[b]=1 => 1
 irb(main):012:0> c.inspect => "{\"K\"=>1}"

and

 irb(main):013:0> a=[1,2] => [1, 2]
 irb(main):014:0> b=[1,2] => [1, 2]
 irb(main):015:0> c={}=> {}
 irb(main):016:0> c[a]=1 => 1
 irb(main):017:0> c[b]=1 => 1
 irb(main):018:0> c.inspect => "{[1, 2]=>1}"

But the hash behaves differently:

 irb(main):019:0> a={1=>2} => {1=>2}
 irb(main):020:0> b={1=>2} => {1=>2}
 irb(main):021:0> c={} => {}
 irb(main):022:0> c[a]=1 => 1
 irb(main):023:0> c[b]=1 => 1
 irb(main):024:0> c.inspect => "{{1=>2}=>1, {1=>2}=>1}"

Why?

I'm going for another coffee ;)

Andrew Walrond