D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Hash
/
Filename :
transform_keys-i.ri
back
Copy
U:RDoc::AnyMethod[iI"transform_keys:ETI"Hash#transform_keys;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"1Returns a new +Hash+ object; each entry has:;To:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"!A key provided by the block.;To;;0; [o; ; [I"The value from +self+.;To:RDoc::Markup::BlankLine o; ; [I"HAn optional hash argument can be provided to map keys to new keys. ;TI"@Any key not given will be mapped using the provided block, ;TI"-or remain the same if no block is given.;T@o; ; [I"Transform keys:;To:RDoc::Markup::Verbatim; [I""h = {foo: 0, bar: 1, baz: 2} ;TI"-h1 = h.transform_keys {|key| key.to_s } ;TI",h1 # => {"foo"=>0, "bar"=>1, "baz"=>2} ;TI" ;TI",h.transform_keys(foo: :bar, bar: :foo) ;TI""#=> {bar: 0, foo: 1, baz: 2} ;TI" ;TI"+h.transform_keys(foo: :hello, &:to_s) ;TI")#=> {:hello=>0, "bar"=>1, "baz"=>2} ;T:@format0o; ; [I"*Overwrites values for duplicate keys:;To;; [I""h = {foo: 0, bar: 1, baz: 2} ;TI")h1 = h.transform_keys {|key| :bat } ;TI"h1 # => {:bat=>2} ;T;0o; ; [I"0Returns a new Enumerator if no block given:;To;; [ I""h = {foo: 0, bar: 1, baz: 2} ;TI"Ye = h.transform_keys # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:transform_keys> ;TI"$h1 = e.each { |key| key.to_s } ;TI"+h1 # => {"foo"=>0, "bar"=>1, "baz"=>2};T;0: @fileI"hash.c;T:0@omit_headings_from_table_of_contents_below0I"�hash.transform_keys {|key| ... } -> new_hash hash.transform_keys(hash2) -> new_hash hash.transform_keys(hash2) {|other_key| ...} -> new_hash hash.transform_keys -> new_enumerator ;T0[ I"(*args);T@?FI" Hash;TcRDoc::NormalClass00