るりまサーチ

最速Rubyリファレンスマニュアル検索!
110件ヒット [1-100件を表示] (0.297秒)

別のキーワード

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

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

Hash#merge(*others) -> Hash (26151.0)

selfとothersのハッシュの内容を順番にマージ(統合)した結果を返します。 デフォルト値はselfの設定のままです。

...d" => 400 }
h1.merge #=> {"a"=>100, "b"=>200}
h1.merge(h2) #=> {"a"=>100, "b"=>246, "c"=>300}
h1.merge(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
h1.merge(h2) {|key, oldval, newval| newval - oldval}
#=> {"a"=>100, "b"=>46, "c"=>300}
h1.merge(h2, h3) {|key,...
.../emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3 => 'c'}
bar = {2 => 'B', 3 => 'C', 4 => '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"...
...{:Australia => 'Sydney',
:France => 'Paris'
}
end
end

h = {:Germany => 'Berlin',
:Australia => 'Canberra',
:France => 'Paris'
}

# 暗黙の変換
p h.merge(Foo.new) # => {:Germany=>"Berlin", :Australia=>"Sydney", :France=>"Paris"}
//}

@see Hash#update,Hash#replace...

Hash#merge(*others) {|key, self_val, other_val| ... } -> Hash (26151.0)

selfとothersのハッシュの内容を順番にマージ(統合)した結果を返します。 デフォルト値はselfの設定のままです。

...d" => 400 }
h1.merge #=> {"a"=>100, "b"=>200}
h1.merge(h2) #=> {"a"=>100, "b"=>246, "c"=>300}
h1.merge(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
h1.merge(h2) {|key, oldval, newval| newval - oldval}
#=> {"a"=>100, "b"=>46, "c"=>300}
h1.merge(h2, h3) {|key,...
.../emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3 => 'c'}
bar = {2 => 'B', 3 => 'C', 4 => '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"...
...{:Australia => 'Sydney',
:France => 'Paris'
}
end
end

h = {:Germany => 'Berlin',
:Australia => 'Canberra',
:France => 'Paris'
}

# 暗黙の変換
p h.merge(Foo.new) # => {:Germany=>"Berlin", :Australia=>"Sydney", :France=>"Paris"}
//}

@see Hash#update,Hash#replace...

Hash#merge(other) -> Hash (26139.0)

selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。

...を返します

//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 254, "c" => 300 }
h1.merge() # => {"a"=>100, "b"=>200}
h1.merge(h2) # => {"a"=>100, "b"=>254, "c"=>300}
h1.merge(h2){|key, oldval, newval| newval - oldval}
# => {"a"=>100, "b"=>54, "c"=>300}
h1...
.../emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3 => 'c'}
bar = {2 => 'B', 3 => 'C', 4 => '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"...
...{:Australia => 'Sydney',
:France => 'Paris'
}
end
end

h = {:Germany => 'Berlin',
:Australia => 'Canberra',
:France => 'Paris'
}

# 暗黙の変換
p h.merge(Foo.new) # => {:Germany=>"Berlin", :Australia=>"Sydney", :France=>"Paris"}
//}

@see Hash#update,Hash#replace...

Hash#merge(other) {|key, self_val, other_val| ... } -> Hash (26139.0)

selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。

...を返します

//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 254, "c" => 300 }
h1.merge() # => {"a"=>100, "b"=>200}
h1.merge(h2) # => {"a"=>100, "b"=>254, "c"=>300}
h1.merge(h2){|key, oldval, newval| newval - oldval}
# => {"a"=>100, "b"=>54, "c"=>300}
h1...
.../emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3 => 'c'}
bar = {2 => 'B', 3 => 'C', 4 => '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"...
...{:Australia => 'Sydney',
:France => 'Paris'
}
end
end

h = {:Germany => 'Berlin',
:Australia => 'Canberra',
:France => 'Paris'
}

# 暗黙の変換
p h.merge(Foo.new) # => {:Germany=>"Berlin", :Australia=>"Sydney", :France=>"Paris"}
//}

@see Hash#update,Hash#replace...

Hash#merge!(*others) -> self (14133.0)

selfとothersのハッシュの内容を順番にマージ(統合)します。

...

//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h1.merge! #=> {"a"=>100, "b"=>200}
h1 #=> {"a"=>100, "b"=>200}
//}

//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h1.merge!(h2) #=> {"a"=>100, "b"=>246, "c"=>300}
h1...
...=> 357, "d" => 400 }
h1.merge!(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
h1 #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
//}

//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h3 = { "b" => 357, "d" => 400 }
h1.merge!(h2, h3) {|key, v1, v2|...
..., 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...

絞り込み条件を変える

Hash#merge!(*others) {|key, self_val, other_val| ... } -> self (14133.0)

selfとothersのハッシュの内容を順番にマージ(統合)します。

...

//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h1.merge! #=> {"a"=>100, "b"=>200}
h1 #=> {"a"=>100, "b"=>200}
//}

//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h1.merge!(h2) #=> {"a"=>100, "b"=>246, "c"=>300}
h1...
...=> 357, "d" => 400 }
h1.merge!(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
h1 #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
//}

//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h3 = { "b" => 357, "d" => 400 }
h1.merge!(h2, h3) {|key, v1, v2|...
..., 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...

Hash#merge!(other) -> self (14115.0)

selfとotherのハッシュの内容をマージ(統合)します。

...クトです。
@return マージ後のselfを返します。

//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 254, "c" => 300 }
h1.merge!(h2) # => {"a"=>100, "b"=>254, "c"=>300}
h1 # => {"a"=>100, "b"=>254, "c"=>300}
//}

//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3...
...'B', 3 => '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#merge!(other) {|key, self_val, other_val| ... } -> self (14115.0)

selfとotherのハッシュの内容をマージ(統合)します。

...クトです。
@return マージ後のselfを返します。

//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 254, "c" => 300 }
h1.merge!(h2) # => {"a"=>100, "b"=>254, "c"=>300}
h1 # => {"a"=>100, "b"=>254, "c"=>300}
//}

//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3...
...'B', 3 => '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(*others) -> self (11033.0)

selfとothersのハッシュの内容を順番にマージ(統合)します。

...

//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h1.merge! #=> {"a"=>100, "b"=>200}
h1 #=> {"a"=>100, "b"=>200}
//}

//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h1.merge!(h2) #=> {"a"=>100, "b"=>246, "c"=>300}
h1...
...=> 357, "d" => 400 }
h1.merge!(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
h1 #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
//}

//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h3 = { "b" => 357, "d" => 400 }
h1.merge!(h2, h3) {|key, v1, v2|...
..., 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...

Hash#update(*others) {|key, self_val, other_val| ... } -> self (11033.0)

selfとothersのハッシュの内容を順番にマージ(統合)します。

...

//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h1.merge! #=> {"a"=>100, "b"=>200}
h1 #=> {"a"=>100, "b"=>200}
//}

//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h1.merge!(h2) #=> {"a"=>100, "b"=>246, "c"=>300}
h1...
...=> 357, "d" => 400 }
h1.merge!(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
h1 #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
//}

//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h3 = { "b" => 357, "d" => 400 }
h1.merge!(h2, h3) {|key, v1, v2|...
..., 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...

絞り込み条件を変える

Hash#update(other) -> self (11015.0)

selfとotherのハッシュの内容をマージ(統合)します。

...クトです。
@return マージ後のselfを返します。

//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 254, "c" => 300 }
h1.merge!(h2) # => {"a"=>100, "b"=>254, "c"=>300}
h1 # => {"a"=>100, "b"=>254, "c"=>300}
//}

//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3...
...'B', 3 => '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 (11015.0)

selfとotherのハッシュの内容をマージ(統合)します。

...クトです。
@return マージ後のselfを返します。

//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 254, "c" => 300 }
h1.merge!(h2) # => {"a"=>100, "b"=>254, "c"=>300}
h1 # => {"a"=>100, "b"=>254, "c"=>300}
//}

//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3...
...'B', 3 => '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!...

Enumerable#slice_before {|elt| bool } -> Enumerator (8007.0)

パターンがマッチした要素、もしくはブロックが真を返した要素から 次にマッチする手前までを チャンク化(グループ化)したものを繰り返す Enumerator を 返します。

..."}, "svn", "proplist", "-R"]) {|f|
f.lines.slice_before(/\AProp/).each {|lines| p lines }
}
#=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"]
# ["Properties on 'goruby.c':\n", " svn:eol-style\n"]
# ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"]
# ["...

Enumerable#slice_before(pattern) -> Enumerator (8007.0)

パターンがマッチした要素、もしくはブロックが真を返した要素から 次にマッチする手前までを チャンク化(グループ化)したものを繰り返す Enumerator を 返します。

..."}, "svn", "proplist", "-R"]) {|f|
f.lines.slice_before(/\AProp/).each {|lines| p lines }
}
#=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"]
# ["Properties on 'goruby.c':\n", " svn:eol-style\n"]
# ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"]
# ["...

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

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

...{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...

絞り込み条件を変える

Object#to_hash -> Hash (8007.0)

オブジェクトの Hash への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。

...すべての場面で代置可能であるような、
* ハッシュそのものとみなせるようなもの
という厳しいものになっています。

//emlist[][ruby]{
class Foo
def to_hash
{'as' => 24}
end
end

it = Foo.new
p({:as => 12}.merge(it)) #=> {"as"=>24, :as=>12}
//}...
<< 1 2 > >>