検索結果
先頭5件
-
Hash
# merge(other) -> Hash (18129) -
selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
...でない
場合は常に other の値を使います。
Hash#merge! は、マージの結果でselfを変更する破壊的メソッドで、Hash#update の別名です。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
@param oth......D'}
p foo.merge(bar) #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo #=> {1=>"a", 2=>"b", 3=>"c"}
p foo.merge!(bar) {|key, foo_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
{:Austr......'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 (18129) -
selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
...でない
場合は常に other の値を使います。
Hash#merge! は、マージの結果でselfを変更する破壊的メソッドで、Hash#update の別名です。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
@param oth......D'}
p foo.merge(bar) #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo #=> {1=>"a", 2=>"b", 3=>"c"}
p foo.merge!(bar) {|key, foo_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
{:Austr......'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) -> self (6129) -
selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
...でない
場合は常に other の値を使います。
Hash#merge! は、マージの結果でselfを変更する破壊的メソッドで、Hash#update の別名です。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
@param oth......D'}
p foo.merge(bar) #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo #=> {1=>"a", 2=>"b", 3=>"c"}
p foo.merge!(bar) {|key, foo_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
{:Austr......'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 (6129) -
selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
...でない
場合は常に other の値を使います。
Hash#merge! は、マージの結果でselfを変更する破壊的メソッドで、Hash#update の別名です。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
@param oth......D'}
p foo.merge(bar) #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo #=> {1=>"a", 2=>"b", 3=>"c"}
p foo.merge!(bar) {|key, foo_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
{:Austr......'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
# update(other) -> self (23) -
selfとotherのハッシュの内容をマージ(統合)します。Hash#merge!と同じです。
...合)します。Hash#merge!と同じです。
デフォルト値はselfの設定のままです。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
@param other マージ用のハッシュまたはメソッド to_hash でハッシュ......> 'C', 4 => 'D'}
p foo.update(bar) #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo.update(bar) {|key, foo_val, bar_val| foo_val + bar_val } #=> {1=>"a", 2=>"BB", 3=>"CC", 4=>"DD"}
p foo #=> {1=>"a", 2=>"BB", 3=>"CC", 4=>"DD"}
@see Hash#merge!... -
Hash
# update(other) {|key , self _ val , other _ val| . . . } -> self (23) -
selfとotherのハッシュの内容をマージ(統合)します。Hash#merge!と同じです。
...合)します。Hash#merge!と同じです。
デフォルト値はselfの設定のままです。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
@param other マージ用のハッシュまたはメソッド to_hash でハッシュ......> 'C', 4 => 'D'}
p foo.update(bar) #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo.update(bar) {|key, foo_val, bar_val| foo_val + bar_val } #=> {1=>"a", 2=>"BB", 3=>"CC", 4=>"DD"}
p foo #=> {1=>"a", 2=>"BB", 3=>"CC", 4=>"DD"}
@see Hash#merge!... -
Hash
# replace(other) -> self (7) -
ハッシュの内容を other の内容で置き換えます。
...ます。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
self = other.to_hash.dup と同じです。
@param other ハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return self......ace(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...
