るりまサーチ

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

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

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

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

...、othersのメソッドto_hashを使って暗黙の変換を試みます。

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

//emlist[][ruby]{
h1 = { "a" => 100, "b" =>...
...#=> {"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 #=> {"a"=>100, "b"=>246, "c"=>300}
//}

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

//emlist[][ruby]{
fo...

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

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

...、othersのメソッドto_hashを使って暗黙の変換を試みます。

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

//emlist[][ruby]{
h1 = { "a" => 100, "b" =>...
...#=> {"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 #=> {"a"=>100, "b"=>246, "c"=>300}
//}

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

//emlist[][ruby]{
fo...

Hash#update(*others) -> self (50.0)

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

...、othersのメソッドto_hashを使って暗黙の変換を試みます。

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

//emlist[][ruby]{
h1 = { "a" => 100, "b" =>...
...#=> {"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 #=> {"a"=>100, "b"=>246, "c"=>300}
//}

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

//emlist[][ruby]{
fo...

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

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

...、othersのメソッドto_hashを使って暗黙の変換を試みます。

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

//emlist[][ruby]{
h1 = { "a" => 100, "b" =>...
...#=> {"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 #=> {"a"=>100, "b"=>246, "c"=>300}
//}

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

//emlist[][ruby]{
fo...

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

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

...、othersのメソッドto_hashを使って暗黙の変換を試みます。

@
param others マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@
return マージした結果を返します

//emlist[][ruby]{
h1 = { "a" => 100, "b" =>...
...newval| newval - oldval}
#=> {"a"=>100, "b"=>311, "c"=>300, "d"=>400}
h1 #=> {"a"=>100, "b"=>200}
//}

//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 #...
...val| foo_val + bar_val }
# => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
p foo # => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
//}

//emlist[][ruby]{
class Foo
def to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end

h = {:Germany => 'Berlin',
:Australia => 'Canberra',...

絞り込み条件を変える

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

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

...、othersのメソッドto_hashを使って暗黙の変換を試みます。

@
param others マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@
return マージした結果を返します

//emlist[][ruby]{
h1 = { "a" => 100, "b" =>...
...newval| newval - oldval}
#=> {"a"=>100, "b"=>311, "c"=>300, "d"=>400}
h1 #=> {"a"=>100, "b"=>200}
//}

//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 #...
...val| foo_val + bar_val }
# => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
p foo # => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
//}

//emlist[][ruby]{
class Foo
def to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end

h = {:Germany => 'Berlin',
:Australia => 'Canberra',...

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

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

...合、otherのメソッドto_hashを使って暗黙の変換を試みます。

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

//emlist[][ruby]{
h1 = { "a" => 100, "b" =>...
...{|key, oldval, newval| newval - oldval}
# => {"a"=>100, "b"=>54, "c"=>300}
h1 # => {"a"=>100, "b"=>200}
//}

//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 #...
...val| foo_val + bar_val }
# => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
p foo # => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
//}

//emlist[][ruby]{
class Foo
def to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end

h = {:Germany => 'Berlin',
:Australia => 'Canberra',...

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

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

...合、otherのメソッドto_hashを使って暗黙の変換を試みます。

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

//emlist[][ruby]{
h1 = { "a" => 100, "b" =>...
...{|key, oldval, newval| newval - oldval}
# => {"a"=>100, "b"=>54, "c"=>300}
h1 # => {"a"=>100, "b"=>200}
//}

//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 #...
...val| foo_val + bar_val }
# => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
p foo # => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
//}

//emlist[][ruby]{
class Foo
def to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end

h = {:Germany => 'Berlin',
:Australia => 'Canberra',...

Hash#transform_keys! -> Enumerator (38.0)

すべてのキーに対してブロックを呼び出した結果でハッシュのキーを変更します。 値は変化しません。

...呼び出した結果でハッシュのキーを変更します。
値は変化しません。

@
param hash 置き換え前のキーから置き換え後のキーへのハッシュを指定します。
@
return transform_keys! は常に self を返します。
ブロックが与えられな...
...# => {:a=>1, :b=>2, :c=>3}
h.transform_keys!(a: "a", d: "d") # => {"a"=>1, :b=>2, :c=>3}
h.transform_keys!.with_index {|k, i| "#{k}.#{i}" }
# => {"a.0"=>1, "b.1"=>2, "c.2"=>3}
//}

@
see Hash#transform_keys
@
see Hash#transform_values
@
see Hash#transform_values!...

Hash#transform_keys! {|key| ... } -> self (38.0)

すべてのキーに対してブロックを呼び出した結果でハッシュのキーを変更します。 値は変化しません。

...呼び出した結果でハッシュのキーを変更します。
値は変化しません。

@
param hash 置き換え前のキーから置き換え後のキーへのハッシュを指定します。
@
return transform_keys! は常に self を返します。
ブロックが与えられな...
...# => {:a=>1, :b=>2, :c=>3}
h.transform_keys!(a: "a", d: "d") # => {"a"=>1, :b=>2, :c=>3}
h.transform_keys!.with_index {|k, i| "#{k}.#{i}" }
# => {"a.0"=>1, "b.1"=>2, "c.2"=>3}
//}

@
see Hash#transform_keys
@
see Hash#transform_values
@
see Hash#transform_values!...

絞り込み条件を変える

Hash#transform_keys!(hash) -> self (38.0)

すべてのキーに対してブロックを呼び出した結果でハッシュのキーを変更します。 値は変化しません。

...呼び出した結果でハッシュのキーを変更します。
値は変化しません。

@
param hash 置き換え前のキーから置き換え後のキーへのハッシュを指定します。
@
return transform_keys! は常に self を返します。
ブロックが与えられな...
...# => {:a=>1, :b=>2, :c=>3}
h.transform_keys!(a: "a", d: "d") # => {"a"=>1, :b=>2, :c=>3}
h.transform_keys!.with_index {|k, i| "#{k}.#{i}" }
# => {"a.0"=>1, "b.1"=>2, "c.2"=>3}
//}

@
see Hash#transform_keys
@
see Hash#transform_values
@
see Hash#transform_values!...

Hash#fetch(key) -> object (32.0)

key に関連づけられた値を返します。該当するキーが登録されてい ない時には、引数 default が与えられていればその値を、ブロッ クが与えられていればそのブロックを評価した値を返します。

...

@
param key 探索するキーを指定します。
@
param default 該当するキーが登録されていない時の返り値を指定します。
@
raise KeyError 引数defaultもブロックも与えられてない時、キーの探索に失敗すると発生します。

//emlist[例][ruby]{...
...o not exist"
"#{key} not exist" # warning: block supersedes default value argument
} # 警告が表示される。

h.default = "default"
p h.fetch(:two) # エラー key not found (KeyError)
//}

@
see Hash#[]...
...wo not exist"
"#{key} not exist" # warning: block supersedes default value argument
} # 警告が表示される。

h.default = "default"
p h.fetch(:two) # エラー key not found (KeyError)
//}

@
see Hash#[]...

Hash#fetch(key) {|key| ... } -> object (32.0)

key に関連づけられた値を返します。該当するキーが登録されてい ない時には、引数 default が与えられていればその値を、ブロッ クが与えられていればそのブロックを評価した値を返します。

...

@
param key 探索するキーを指定します。
@
param default 該当するキーが登録されていない時の返り値を指定します。
@
raise KeyError 引数defaultもブロックも与えられてない時、キーの探索に失敗すると発生します。

//emlist[例][ruby]{...
...o not exist"
"#{key} not exist" # warning: block supersedes default value argument
} # 警告が表示される。

h.default = "default"
p h.fetch(:two) # エラー key not found (KeyError)
//}

@
see Hash#[]...
...wo not exist"
"#{key} not exist" # warning: block supersedes default value argument
} # 警告が表示される。

h.default = "default"
p h.fetch(:two) # エラー key not found (KeyError)
//}

@
see Hash#[]...

Hash#fetch(key, default) -> object (32.0)

key に関連づけられた値を返します。該当するキーが登録されてい ない時には、引数 default が与えられていればその値を、ブロッ クが与えられていればそのブロックを評価した値を返します。

...

@
param key 探索するキーを指定します。
@
param default 該当するキーが登録されていない時の返り値を指定します。
@
raise KeyError 引数defaultもブロックも与えられてない時、キーの探索に失敗すると発生します。

//emlist[例][ruby]{...
...o not exist"
"#{key} not exist" # warning: block supersedes default value argument
} # 警告が表示される。

h.default = "default"
p h.fetch(:two) # エラー key not found (KeyError)
//}

@
see Hash#[]...
...wo not exist"
"#{key} not exist" # warning: block supersedes default value argument
} # 警告が表示される。

h.default = "default"
p h.fetch(:two) # エラー key not found (KeyError)
//}

@
see Hash#[]...
<< 1 2 3 ... > >>