invert()
public
Returns a new hash created by using
hsh’s values as keys, and
the keys as values.
h = { "n" => 100, "m" => 100, "y" => 300, "d" => 200, "a" => 0 }
h.invert
Show source
/*
* call-seq:
* hsh.invert -> aHash
*
* Returns a new hash created by using <i>hsh</i>'s values as keys, and
* the keys as values.
*
* h = { "n" => 100, "m" => 100, "y" => 300, "d" => 200, "a" => 0 }
* h.invert #=> {0=>"a", 100=>"n", 200=>"d", 300=>"y"}
*
*/
static VALUE
rb_hash_invert(hash)
VALUE hash;
{
VALUE h = rb_hash_new();
rb_hash_foreach(hash, rb_hash_invert_i, h);
return h;
}