ts <decoux / moulon.inra.fr> writes:

> D> string is used as a hash key, it is copied automatically, so that
> D> subsequent changes to the string don't affect the hash.
> 
>  copy-on-write, like regexp

  a = "hello"	
  h = { a => 1 }
  b = h.keys[0]	
  a.id		# => 537675084
  b.id		# => 537675424

  a = "hello".freeze
  h = { a => 1 }	
  b = h.keys[0]		
  a.id		# => 537675074
  b.id		# => 537675074

Seems to copy on insert unless the original is frozen.


Dave