種類
- インスタンスメソッド (604)
- 特異メソッド (27)
ライブラリ
- ビルトイン (631)
キーワード
- < (9)
- <= (9)
- == (11)
- === (11)
- > (9)
- >= (9)
- [] (11)
- assoc (11)
- clear (11)
-
compare
_ by _ identity (11) -
compare
_ by _ identity? (11) -
default
_ proc (11) -
delete
_ if (11) - each (11)
-
each
_ key (11) -
each
_ pair (22) -
each
_ value (11) - eql? (11)
- equal? (11)
- filter (12)
- filter! (12)
- flatten (11)
- hash (11)
- inspect (11)
- invert (11)
-
keep
_ if (17) - length (11)
- member? (11)
- merge (22)
- merge! (22)
- rassoc (11)
- rehash (11)
- reject (22)
- reject! (22)
- replace (11)
-
ruby2
_ keywords _ hash? (5) - select (17)
- select! (17)
- size (11)
- store (11)
-
to
_ a (11) -
to
_ proc (9) -
to
_ s (11) -
transform
_ keys (17) -
transform
_ keys! (17) -
transform
_ values (16) -
transform
_ values! (16) -
try
_ convert (11) - update (22)
検索結果
先頭5件
-
Hash
# default _ proc -> Proc | nil (6301.0) -
ハッシュのデフォルト値を返す Proc オブジェクトを返します。 ハッシュがブロック形式のデフォルト値を持たない場合 nil を返します。
...Proc オブジェクトを返します。
ハッシュがブロック形式のデフォルト値を持たない場合 nil を返します。
//emlist[例][ruby]{
h = Hash.new {|hash, key| "The #{key} not exist in #{hash.inspect}"}
p h.default #=> nil
p block = h.default_proc #=> #<Pro......c:0x0x401a9ff4>
p block.call({},:foo) #=> "The foo not exist in {}"
h = Hash.new("default")
p h.default #=> "default"
p h.default_proc #=> nil
//}
@see Hash#default... -
Hash
# filter -> Enumerator (6301.0) -
key, value のペアについてブロックを評価し,真となるペアだけを含む ハッシュを生成して返します。
...った場合は、自身と select から生成した
Enumerator オブジェクトを返します。
//emlist[][ruby]{
h = { "a" => 100, "b" => 200, "c" => 300 }
h.select {|k,v| k > "a"} #=> {"b" => 200, "c" => 300}
h.select {|k,v| v < 200} #=> {"a" => 100}
//}
@see Hash#select!, Hash#reject... -
Hash
# rassoc(value) -> Array | nil (6301.0) -
ハッシュ内を検索して,引数 value と 一致する値を探します。
...とするサイズ 2 の配列を返します。
ない場合には nil を返します。
@param value 探索する値。
//emlist[例][ruby]{
a = {1=> "one", 2 => "two", 3 => "three", "ii" => "two"}
a.rassoc("two") #=> [2, "two"]
a.rassoc("four") #=> nil
//}
@see Hash#assoc, Array#rassoc... -
Hash
# to _ proc -> Proc (6301.0) -
self のキーに対応する値を返す Proc オブジェクトを返します。
...self のキーに対応する値を返す Proc オブジェクトを返します。
//emlist[][ruby]{
h = {1 => 10, 2 => 20, 3 => 30}
[1, 2, 3].map(&h) # => [10, 20, 30]
//}... -
Hash
# transform _ keys -> Enumerator (6301.0) -
すべてのキーに対してブロックを呼び出した結果で置き換えたハッシュを返します。 値は変化しません。
...ruby]{
h = { a: 1, b: 2, c: 3 }
h.transform_keys {|k| k.to_s } # => {"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#transfor......m_keys!
@see Hash#transform_values
@see Hash#transform_values!......。
@param hash 置き換え前のキーから置き換え後のキーへのハッシュを指定します。
//emlist[例][ruby]{
h = { a: 1, b: 2, c: 3 }
h.transform_keys {|k| k.to_s } # => {"a"=>1, "b"=>2, "c"=>3}
h.transform_keys(a: "a", d: "d") # => {"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 (6301.0) -
すべてのキーに対してブロックを呼び出した結果でハッシュのキーを変更します。 値は変化しません。
...@return transform_keys! は常に self を返します。
ブロックが与えられなかった場合は、Enumerator オブジェクトを
返します。
//emlist[例][ruby]{
h = { a: 1, b: 2, c: 3 }
h.transform_keys! {|k| k.to_s } # => {"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!......@param hash 置き換え前のキーから置き換え後のキーへのハッシュを指定します。
@return transform_keys! は常に self を返します。
ブロックが与えられなかった場合は、Enumerator オブジェクトを
返します。
//emlist[例][ruby......]{
h = { a: 1, b: 2, c: 3 }
h.transform_keys! {|k| k.to_s } # => {"a"=>1, "b"=>2, "c"=>3}
h.transform_keys!(&:to_sym) # => {: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 _ values -> Enumerator (6301.0) -
すべての値に対してブロックを呼び出した結果で置き換えたハッシュを返します。 キーは変化しません。
...。
@return 置き換えたハッシュを返します。
ブロックが与えられなかった場合は、Enumerator オブジェクトを
返します。
//emlist[例][ruby]{
h = { a: 1, b: 2, c: 3 }
h.transform_values {|v| v * v + 1 } #=> { a: 2, b: 5, c: 10 }
h.transform_val......ues(&: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!......ues(&: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!... -
Hash
# transform _ values! -> Enumerator (6301.0) -
すべての値に対してブロックを呼び出した結果でハッシュの値を変更します。 キーは変化しません。
...@return transform_values! は常に self を返します。
ブロックが与えられなかった場合は、Enumerator オブジェクトを
返します。
//emlist[例][ruby]{
h = { a: 1, b: 2, c: 3 }
h.transform_values! {|v| v * v + 1 } #=> { a: 2, b: 5, c: 10 }
h.transform_......values!(&:to_s) #=> { a: "2", b: "5", c: "10" }
h.transform_values!.with_index {|v, i| "#{v}.#{i}" }
#=> { a: "2.0", b: "5.1", c: "10.2" }
//}
@see Hash#transform_values......values!(&:to_s) #=> { a: "2", b: "5", c: "10" }
h.transform_values!.with_index {|v, i| "#{v}.#{i}" }
#=> { a: "2.0", b: "5.1", c: "10.2" }
//}
@see Hash#transform_values
@see Hash#transform_keys
@see Hash#transform_keys!... -
Hash
# merge(*others) -> Hash (6213.0) -
selfとothersのハッシュの内容を順番にマージ(統合)した結果を返します。 デフォルト値はselfの設定のままです。
...selfとothersのハッシュの内容を順番にマージ(統合)した結果を返します。
デフォルト値はselfの設定のままです。
self と others に同じキーがあった場合はブロック付きか否かで
判定方法が違います。ブロック付きのときはブ......に others の値を使います。
othersがハッシュではない場合、othersのメソッドto_hashを使って暗黙の変換を試みます。
@param others マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マー......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,... -
Hash
# merge(*others) {|key , self _ val , other _ val| . . . } -> Hash (6213.0) -
selfとothersのハッシュの内容を順番にマージ(統合)した結果を返します。 デフォルト値はselfの設定のままです。
...selfとothersのハッシュの内容を順番にマージ(統合)した結果を返します。
デフォルト値はselfの設定のままです。
self と others に同じキーがあった場合はブロック付きか否かで
判定方法が違います。ブロック付きのときはブ......に others の値を使います。
othersがハッシュではない場合、othersのメソッドto_hashを使って暗黙の変換を試みます。
@param others マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マー......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,... -
Hash
# merge(other) -> Hash (6207.0) -
selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
...selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
self と other に同じキーがあった場合はブロック付きか否かで
判定方法が違います。ブロック付きのときはブロックを......に other の値を使います。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
@param other マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マージ......した結果を返します
//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"=... -
Hash
# merge(other) {|key , self _ val , other _ val| . . . } -> Hash (6207.0) -
selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
...selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
self と other に同じキーがあった場合はブロック付きか否かで
判定方法が違います。ブロック付きのときはブロックを......に other の値を使います。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
@param other マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マージ......した結果を返します
//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"=... -
Hash
# clear -> self (6201.0) -
ハッシュの中身を空にします。
...ハッシュの中身を空にします。
空にした後のselfを返します。
デフォルト値の設定はクリアされません。
//emlist[例][ruby]{
h = Hash.new("default value")
h[:some] = "some"
p h #=> {:some=>"some"}
h.clear
p h #=> {}
p h.default #=> "default value"
//}...