検索結果
先頭5件
-
Hash
# replace(other) -> self (18114) -
ハッシュの内容を other の内容で置き換えます。
...ます。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
self = other.to_hash.dup と同じです。
@param other ハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return self......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... -
Hash
# merge!(other) -> self (7) -
selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
...でない
場合は常に other の値を使います。
Hash#merge! は、マージの結果でselfを変更する破壊的メソッドで、Hash#update の別名です。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
@param oth......_val, bar_val| foo_val + bar_val } #=> {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
p foo #=> {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
class Foo
def to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end
h = {:Germany => 'Berlin',
:Australia => 'Canberra',......:France => 'Paris'
}
h.merge!(Foo.new) #暗黙の変換
p h #=> {:Germany=>"Berlin", :Australia=>"Sydney", :France=>"Paris"}
@see Hash#update,Hash#replace... -
Hash
# merge!(other) {|key , self _ val , other _ val| . . . } -> self (7) -
selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
...でない
場合は常に other の値を使います。
Hash#merge! は、マージの結果でselfを変更する破壊的メソッドで、Hash#update の別名です。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
@param oth......_val, bar_val| foo_val + bar_val } #=> {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
p foo #=> {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
class Foo
def to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end
h = {:Germany => 'Berlin',
:Australia => 'Canberra',......:France => 'Paris'
}
h.merge!(Foo.new) #暗黙の変換
p h #=> {:Germany=>"Berlin", :Australia=>"Sydney", :France=>"Paris"}
@see Hash#update,Hash#replace... -
Hash
# merge(other) -> Hash (7) -
selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
...でない
場合は常に other の値を使います。
Hash#merge! は、マージの結果でselfを変更する破壊的メソッドで、Hash#update の別名です。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
@param oth......_val, bar_val| foo_val + bar_val } #=> {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
p foo #=> {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
class Foo
def to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end
h = {:Germany => 'Berlin',
:Australia => 'Canberra',......:France => 'Paris'
}
h.merge!(Foo.new) #暗黙の変換
p h #=> {:Germany=>"Berlin", :Australia=>"Sydney", :France=>"Paris"}
@see Hash#update,Hash#replace... -
Hash
# merge(other) {|key , self _ val , other _ val| . . . } -> Hash (7) -
selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
...でない
場合は常に other の値を使います。
Hash#merge! は、マージの結果でselfを変更する破壊的メソッドで、Hash#update の別名です。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
@param oth......_val, bar_val| foo_val + bar_val } #=> {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
p foo #=> {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
class Foo
def to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end
h = {:Germany => 'Berlin',
:Australia => 'Canberra',......:France => 'Paris'
}
h.merge!(Foo.new) #暗黙の変換
p h #=> {:Germany=>"Berlin", :Australia=>"Sydney", :France=>"Paris"}
@see Hash#update,Hash#replace...
