るりまサーチ (Ruby 2.3.0)

最速Rubyリファレンスマニュアル検索!
1件ヒット [1-1件を表示] (0.015秒)
トップページ > クラス:Hash[x] > バージョン:2.3.0[x] > クエリ:dup[x] > クエリ:replace[x]

別のキーワード

  1. _builtin dup
  2. set dup
  3. singleton dup
  4. etc sc_re_dup_max
  5. bigdecimal dup

ライブラリ

検索結果

Hash#replace(other) -> self (54397.0)

ハッシュの内容を other の内容で置き換えます。

...ます。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。

self = other.to_hash.dup と同じです。

@param other ハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return self...
...{2 => 'B', 3 => 'C'}

foo.replace(bar)
p foo #=> {2=>"B", 3=>"C"}

zoo = {}
zoo = bar.dup
p zoo #=> {2=>"B", 3=>"C"}

class Foo
def to_hash
{:japan => 'kyoto'}
end
end

h = Hash.new
h.replace(Foo.new) #暗黙の変換
p h #=> {:japan=>"kyoto"}
//}

@see Hash#dup,Hash#merge,Object#to_hash...