るりまサーチ

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

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

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

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

...ハッシュではない場合、othersのメソッドto_hashを使って暗黙の変換を試みます。

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

//emlist[][rub...
..., 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, oldval, newval| newval - oldval}
#=> {"a"=>100, "b"=>311, "c"=>300, "d"=>400}
h1 #=>...
...to_hash
{: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#r...

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

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

...ハッシュではない場合、othersのメソッドto_hashを使って暗黙の変換を試みます。

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

//emlist[][rub...
..., 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, oldval, newval| newval - oldval}
#=> {"a"=>100, "b"=>311, "c"=>300, "d"=>400}
h1 #=>...
...to_hash
{: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#r...

Hash#transform_keys! -> Enumerator (132.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 (132.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 (132.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 (126.0)

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

...ていても単に無視します(挙動に変化がありません)。

@
param key 探索するキーを指定します。
@
param default 該当するキーが登録されていない時の返り値を指定します。
@
raise KeyError 引数defaultもブロックも与えられてない時...
...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 (126.0)

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

...ていても単に無視します(挙動に変化がありません)。

@
param key 探索するキーを指定します。
@
param default 該当するキーが登録されていない時の返り値を指定します。
@
raise KeyError 引数defaultもブロックも与えられてない時...
...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 (126.0)

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

...ていても単に無視します(挙動に変化がありません)。

@
param key 探索するキーを指定します。
@
param default 該当するキーが登録されていない時の返り値を指定します。
@
raise KeyError 引数defaultもブロックも与えられてない時...
...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#merge(other) -> Hash (126.0)

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

...がハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。

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

//emlist[][ru...
...4, "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 # => {"a"=>100, "b"=>200}
//}

//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b'...
...to_hash
{: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#r...

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

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

...がハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。

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

//emlist[][ru...
...4, "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 # => {"a"=>100, "b"=>200}
//}

//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b'...
...to_hash
{: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#r...

絞り込み条件を変える

Hash#transform_keys -> Enumerator (126.0)

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

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

@
param hash 置き換え前のキーから置き換え後のキーへのハッシュを指定します。

//emlist[例][ruby]{
h = { a: 1, b: 2, c: 3 }
h....
...") # => {"a"=>1, :b=>2, :c=>3}
h.transform_keys(&:to_s) # => {"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| ... } -> Hash (126.0)

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

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

@
param hash 置き換え前のキーから置き換え後のキーへのハッシュを指定します。

//emlist[例][ruby]{
h = { a: 1, b: 2, c: 3 }
h....
...") # => {"a"=>1, :b=>2, :c=>3}
h.transform_keys(&:to_s) # => {"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! -> Enumerator (126.0)

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

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

@
return transform_keys! は常に self を返します。
ブロックが与えられなかった場合は、Enumerator オブジェクトを...
...# => {"a"=>1, "b"=>2, "c"=>3}
h.transform_keys!(&:to_sym) # => {: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 (126.0)

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

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

@
return transform_keys! は常に self を返します。
ブロックが与えられなかった場合は、Enumerator オブジェクトを...
...# => {"a"=>1, "b"=>2, "c"=>3}
h.transform_keys!(&:to_sym) # => {: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) -> Hash (126.0)

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

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

@
param hash 置き換え前のキーから置き換え後のキーへのハッシュを指定します。

//emlist[例][ruby]{
h = { a: 1, b: 2, c: 3 }
h....
...") # => {"a"=>1, :b=>2, :c=>3}
h.transform_keys(&:to_s) # => {"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_values -> Enumerator (126.0)

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

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

@
return 置き換えたハッシュを返します。
ブロックが与えられなかった場合は、Enumerator オブジェクトを...
...{ a: 2, b: 5, c: 10 }
h.transform_values(&:to_s) #=> { a: "1", b: "2", c: "3" }
h.transform_values.with_index {|v, i| "#{v}.#{i}" }
#=> { a: "1.0", b: "2.1", c: "3.2" }
//}

@
see Hash#transform_values!
@
see Hash#transform_keys
@
see Hash#transform_keys!...
<< 1 2 3 ... > >>