ライブラリ
- ビルトイン (982)
キーワード
- < (9)
- <= (9)
- == (11)
- === (11)
- >= (9)
- [] (11)
- assoc (11)
- clear (11)
- clone (11)
- compact (8)
- compact! (8)
-
compare
_ by _ identity (11) -
compare
_ by _ identity? (11) - default (22)
-
default
_ proc (11) - delete (22)
-
delete
_ if (22) - dig (9)
- dup (11)
- each (22)
-
each
_ key (22) -
each
_ pair (22) -
each
_ value (22) - empty? (11)
- eql? (11)
- equal? (11)
- except (3)
- fetch (33)
-
fetch
_ values (18) - filter (12)
- filter! (12)
- flatten (11)
-
has
_ key? (11) -
has
_ value? (11) - hash (11)
- include? (11)
- index (7)
- inspect (11)
- invert (11)
-
keep
_ if (22) - key (11)
- key? (11)
- keys (11)
- length (11)
- member? (11)
- merge (22)
- merge! (22)
- rassoc (11)
- rehash (11)
- reject (22)
- reject! (22)
- replace (11)
- select (22)
- select! (22)
- shift (11)
- size (11)
- slice (7)
- store (11)
-
to
_ a (11) -
to
_ h (17) -
to
_ hash (11) -
to
_ proc (9) -
to
_ s (11) -
transform
_ keys (17) -
transform
_ keys! (17) -
transform
_ values (16) -
transform
_ values! (16) - update (22)
- value? (11)
- values (11)
-
values
_ at (11)
検索結果
先頭5件
-
Hash
# >(other) -> bool (39144.0) -
other が self のサブセットである場合に真を返します。
...サブセットである場合に真を返します。
@param other 自身と比較したい Hash オブジェクトを指定します。
//emlist[例][ruby]{
h1 = {a:1, b:2}
h2 = {a:1, b:2, c:3}
h1 > h2 # => false
h2 > h1 # => true
h1 > h1 # => false
//}
@see Hash#<=, Hash#<, Hash#>=... -
Hash
# to _ hash -> self (27251.0) -
self を返します。
...self を返します。
//emlist[例][ruby]{
hash = {}
p hash.to_hash # => {}
p hash.to_hash == hash # => true
//}
@see Object#to_hash, Hash#to_h... -
Hash
# hash -> Integer (27215.0) -
自身が保持するキーと値のハッシュ値を元にして算出した整数を返します。 自身が保持するキーや値が変化すればこのメソッドが返す値も変化します。
...自身が保持するキーと値のハッシュ値を元にして算出した整数を返します。
自身が保持するキーや値が変化すればこのメソッドが返す値も変化します。
//emlist[例][ruby]{
a = {}
p a.hash #=> 0
a[1] = :x
p a.hash #=> 329543
//}... -
Hash
# rehash -> self (27214.0) -
キーのハッシュ値を再計算します。
...raise RuntimeError Hash#eachなどのイテレータの評価途中でrehashすると発生します。
@return selfを返します。
//emlist[例][ruby]{
a = [ "a", "b" ]
h = { a => 100 }
p h[a] #=> 100
a[0] = "z"
p h[a] #=> nil
h.rehash
p h[a] #=> 100
//}
@see Object#hash... -
Hash
# >=(other) -> bool (27126.0) -
other が self のサブセットか同じである場合に真を返します。
...セットか同じである場合に真を返します。
@param other 自身と比較したい Hash オブジェクトを指定します。
//emlist[例][ruby]{
h1 = {a:1, b:2}
h2 = {a:1, b:2, c:3}
h1 >= h2 # => false
h2 >= h1 # => true
h1 >= h1 # => true
//}
@see Hash#<=, Hash#<, Hash#>... -
Hash
# transform _ keys(hash) -> Hash (21329.0) -
すべてのキーに対してブロックを呼び出した結果で置き換えたハッシュを返します。 値は変化しません。
...ん。
@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_key......s(&: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
# to _ h -> self | Hash (21308.0) -
self を返します。Hash クラスのサブクラスから呼び出した場合は self を Hash オブジェクトに変換します。
...す。Hash クラスのサブクラスから呼び出した場合は
self を Hash オブジェクトに変換します。
//emlist[例][ruby]{
hash = {}
p hash.to_h # => {}
p hash.to_h == hash # => true
class MyHash < Hash;end
my_hash = MyHash.new
p my_hash.to_h # => {}
p my_hash.clas......=> MyHash
p my_hash.to_h.class # => Hash
//}
ブロックを指定すると各ペアでブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
hash = { "a" => 97, "b" => 98 }
hash.to_h {|key, value| [key.upcase, value-32] } # => {"A"=>......65, "B"=>66}
//}
@see Enumerable#map... -
Hash
# to _ h {|key , value| block } -> Hash (21308.0) -
self を返します。Hash クラスのサブクラスから呼び出した場合は self を Hash オブジェクトに変換します。
...す。Hash クラスのサブクラスから呼び出した場合は
self を Hash オブジェクトに変換します。
//emlist[例][ruby]{
hash = {}
p hash.to_h # => {}
p hash.to_h == hash # => true
class MyHash < Hash;end
my_hash = MyHash.new
p my_hash.to_h # => {}
p my_hash.clas......=> MyHash
p my_hash.to_h.class # => Hash
//}
ブロックを指定すると各ペアでブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
hash = { "a" => 97, "b" => 98 }
hash.to_h {|key, value| [key.upcase, value-32] } # => {"A"=>......65, "B"=>66}
//}
@see Enumerable#map... -
Hash
# to _ h -> self | Hash (21295.0) -
self を返します。Hash クラスのサブクラスから呼び出した場合は self を Hash オブジェクトに変換します。
...す。Hash クラスのサブクラスから呼び出した場合は
self を Hash オブジェクトに変換します。
//emlist[例][ruby]{
hash = {}
p hash.to_h # => {}
p hash.to_h == hash # => true
class MyHash < Hash;end
my_hash = MyHash.new
p my_hash.to_h # => {}
p my_hash.clas......s # => MyHash
p my_hash.to_h.class # => Hash
//}... -
Hash
# compact -> Hash (21255.0) -
compact は自身から value が nil のもの取り除いた Hash を生成して返します。 compact! は自身から破壊的に value が nil のものを取り除き、変更が行われた場合は self を、そうでなければ nil を返します。
...た Hash を生成して返します。 compact! は自身から破壊的に value が nil のものを取り除き、変更が行われた場合は self を、そうでなければ nil を返します。
//emlist[例][ruby]{
hash = {a: 1, b: nil, c: 3}
p hash.compact #=> {:a=>1, :c=>3}
p hash......#=> {:a=>1, :b=>nil, :c=>3}
hash.compact!
hash #=> {:a=>1, :c=>3}
p hash.compact! #=> nil
//}
@see Array#compact... -
Hash
# merge(*others) -> Hash (21234.0) -
selfとothersのハッシュの内容を順番にマージ(統合)した結果を返します。 デフォルト値はselfの設定のままです。
...to_hashを使って暗黙の変換を試みます。
@param others マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マージした結果を返します
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246,......> 300 }
h3 = { "b" => 357, "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"=>......#=> {"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 # => {1=>"a", 2=>"b", 3=>"c"}
p foo... -
Hash
# merge(*others) {|key , self _ val , other _ val| . . . } -> Hash (21234.0) -
selfとothersのハッシュの内容を順番にマージ(統合)した結果を返します。 デフォルト値はselfの設定のままです。
...to_hashを使って暗黙の変換を試みます。
@param others マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マージした結果を返します
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246,......> 300 }
h3 = { "b" => 357, "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"=>......#=> {"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 # => {1=>"a", 2=>"b", 3=>"c"}
p foo... -
Hash
# merge(other) -> Hash (21234.0) -
selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
...to_hashを使って暗黙の変換を試みます。
@param other マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マージした結果を返します
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 254,......=> 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', 3 =>......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"}
p foo # => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
//}... -
Hash
# merge(other) {|key , self _ val , other _ val| . . . } -> Hash (21234.0) -
selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
...to_hashを使って暗黙の変換を試みます。
@param other マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マージした結果を返します
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 254,......=> 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', 3 =>......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"}
p foo # => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
//}...