U:RDoc::AnyMethod[iI" invert:ETI"Hash#invert;TF: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [ I"JReturns a new hash created by using hsh's values as keys, and ;TI"the keys as values. ;TI"IIf a key with the same value already exists in the hsh, then ;TI"Othe last one defined will be used, the earlier value(s) will be discarded.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"Fh = { "n" => 100, "m" => 100, "y" => 300, "d" => 200, "a" => 0 } ;TI";h.invert #=> {0=>"a", 100=>"m", 200=>"d", 300=>"y"} ;T: @format0o; ; [I"GIf there is no key with the same value, Hash#invert is involutive.;T@o; ; [I"h = { a: 1, b: 3, c: 4 } ;TI"#h.invert.invert == h #=> true ;T; 0o; ; [I"KThe condition, no key with the same value, can be tested by comparing ;TI"the size of inverted hash.;T@o; ; [ I""# no key with the same value ;TI"h = { a: 1, b: 3, c: 4 } ;TI"&h.size == h.invert.size #=> true ;TI" ;TI"-# two (or more) keys has the same value ;TI"h = { a: 1, b: 3, c: 1 } ;TI"&h.size == h.invert.size #=> false;T; 0: @fileI" hash.c;T:0@omit_headings_from_table_of_contents_below0I"hsh.invert -> new_hash ;T0[I"();T@*FI" Hash;TcRDoc::NormalClass00