On Feb 4, 1:37 pm, Yukihiro Matsumoto <m... / ruby-lang.org> wrote:
> Hi,
>
> In message "Re: Hash#rekey"
>     on Mon, 5 Feb 2007 03:08:15 +0900, "Trans" <transf... / gmail.com> writes:
>
> |> No.  "foo" and :foo are different keys in a hash.
> |
> |And never the twain shall meet? So it's long live
> |HashWithIndifferentAccess ?
>
> The HashWithIndifferentAccess behavior will not be default even after
> Ruby 2.0; that's for sure.

Okay, well I though the whole reason you considerd making Symbols a
subclass of String was basically to remove the need for this sort of
thing. Honestly, keyword lists are increasing common as prameter args
and I for get tired of putting

  opts = opts.stringify_keys

at the beginning of every such method. not to mention normalizing keys
when the are stored in such hash.

> |A while back I offered the idea of being able to define a key coerce
> |proc, eg.
> |
> |  h = Hash.new.key!{ |k| k.to_s }
> |
> |Such that keys would always be strings. Might someting like that be a
> |viable solution?
>
> Maybe, but not with a name like "key!".
>
> |In anycase, I still offer up #rekey.
>
> I don't think "rekey" represents the behavior well.  Any better name?
> transpose_keys comes to my mind.

I used 'normalize_keys' for while, but how doesn't 'rekey' fit the
behavior? The hash is being rekey'd.

T.