gotoken / math.sci.hokudai.ac.jp (GOTO Kentaro) writes:

> I see.  But I don't know the purpose of Hash#invert.  IMHO, invert is
> not a so general method to be built-in...

I've used it a couple of times, but I agree it's rare.

As an artificial example:

  e_2_j = { "one" => "ichi", "two" => "ni", "three" => "san" }
  j_2_e = e_2_j.invert

Of course this breaks down at "shi" => "four", "yon" => "four", but
there are many true one-to-one mappings where .invert can be useful.


Dave