るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

クラス

検索結果

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

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

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

@param other ハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return self を返します。

//emlist[例][ruby]{
foo = {1 => 'a', 2 => 'b'}
bar = {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...