Brian Adkins wrote:
> 
> Why would that cause this effect though? The docs say "a String passed
> as a key will be duplicated and frozen", but duplicating and freezing
> a TestStr doesn't nullify dupstr:

The answer lies in the rb_hash_aset() function I quoted.  rb_str_new4() 
begins like this:

  VALUE
  rb_str_new4(orig)
      VALUE orig;
  {
      VALUE klass, str;

      if (OBJ_FROZEN(orig)) return orig;
      /* ... */
  }

Like Robert showed, if it's already frozen then the key is untouched (no 
dup+freeze).

The docs could be made clearer: An _unfrozen_ String passed as a key 
will be duplicated and frozen.
-- 
Posted via http://www.ruby-forum.com/.