1411件ヒット
[1-100件を表示]
(0.181秒)
別のキーワード
ライブラリ
- ビルトイン (1245)
- abbrev (12)
- csv (24)
- erb (8)
- json (12)
-
json
/ add / bigdecimal (12) -
json
/ add / exception (12) - optparse (36)
- ostruct (14)
-
rexml
/ document (24) -
webrick
/ httprequest (12)
クラス
- Array (68)
- BigDecimal (12)
-
CSV
:: Table (24) - Data (3)
- ERB (8)
-
Encoding
:: Converter (48) - Exception (12)
- Hash (680)
- MatchData (12)
- Method (12)
- Module (12)
- Numeric (12)
- Object (60)
- OpenStruct (14)
- OptionParser (24)
-
REXML
:: Attributes (12) -
REXML
:: Element (12) -
RubyVM
:: InstructionSequence (12) - String (228)
- Struct (17)
- UnboundMethod (24)
-
WEBrick
:: HTTPRequest (12)
モジュール
キーワード
- % (12)
- < (10)
- <= (10)
- == (12)
- === (12)
- > (10)
- >= (10)
- [] (12)
- abbrev (12)
-
add
_ attributes (12) - collect (21)
- compact (9)
- compact! (9)
-
compare
_ by _ identity (12) -
compare
_ by _ identity? (12) - default (24)
- delete (24)
- dig (30)
- each (12)
-
each
_ key (12) -
each
_ pair (12) -
each
_ value (12) - empty? (12)
- encode (36)
- eql? (48)
- equal? (12)
- except (4)
- fetch (36)
-
fetch
_ values (20) - filter (14)
- filter! (14)
- getopts (36)
-
group
_ by (12) - gsub (48)
- gsub! (48)
- index (7)
- intersection (6)
- invert (12)
-
is
_ a? (12) -
keep
_ if (19) - key (12)
- keys (12)
-
kind
_ of? (12) - map (21)
- merge (24)
- merge! (24)
-
named
_ captures (12) - namespaces (12)
- owner (12)
-
primitive
_ convert (48) - query (12)
- replace (12)
- result (8)
-
ruby2
_ keywords (12) - select (24)
- select! (24)
- shift (12)
- store (12)
- sub (36)
- sub! (36)
- tally (10)
-
to
_ a (12) -
to
_ csv (12) -
to
_ h (64) -
to
_ hash (12) -
to
_ json (36) -
to
_ s (12) -
transform
_ keys (20) -
transform
_ keys! (20) -
transform
_ values (18) -
transform
_ values! (18) - union (7)
- update (24)
- values (12)
-
values
_ at (12)
検索結果
先頭5件
-
Object
# hash -> Integer (24450.0) -
オブジェクトのハッシュ値を返します。このハッシュ値は、Object#eql? と合わせて Hash クラスで、2つのオブジェクトを同一のキーとするか判定するために用いられます。
...オブジェクトのハッシュ値を返します。このハッシュ値は、Object#eql? と合わせて Hash クラスで、2つのオブジェクトを同一のキーとするか判定するために用いられます。
2つのオブジェクトのハッシュ値が異なるとき、直ち......に Object#eql? での比較により判定されます。
そのため、同じキーとして判定される状況は Object#eql? の比較で真となる場合のみであり、このとき前段階としてハッシュ値どうしが等しい必要があります。
つまり、
A.eql?(B) な......らば A.hash == B.hash
の関係が満たされている必要があります。
ただし、ハッシュのキーとして Integer, Symbol, String などの特定の組み込みクラスが使われるときは、組込みのハッシュ関数が使用され、hash メソッドは呼ばれませ... -
UnboundMethod
# hash -> Integer (24344.0) -
自身のハッシュ値を返します。
...自身のハッシュ値を返します。
//emlist[例][ruby]{
a = method(:==).unbind
b = method(:eql?).unbind
p a.eql? b # => true
p a.hash == b.hash # => true
p [a, b].uniq.size # => 1
//}... -
Method
# hash -> Integer (21344.0) -
自身のハッシュ値を返します。
...自身のハッシュ値を返します。
//emlist[例][ruby]{
a = method(:==)
b = method(:eql?)
p a.eql? b # => true
p a.hash == b.hash # => true
p [a, b].uniq.size # => 1
//}... -
Hash
# compare _ by _ identity -> self (21319.0) -
ハッシュのキーの一致判定をオブジェクトの同一性で判定するように変更します。
...り厳密に
Object#object_idが一致しているかどうかを条件とするようにselfを変更します。
selfが変化する破壊的メソッドです。
@return selfを返します。
//emlist[例][ruby]{
h1 = { "a" => 100, "b" => 200, :c => "c" }
p h1.compare_by_identity? #=> false
p......h1["a"] #=> 100
h1.compare_by_identity
p h1.compare_by_identity? #=> true
p h1["a"] #=> nil # この"a"と最初の"a"とは違うオブジェクト
p h1[:c] #=> "c" # 同じ内容のシンボルはすべて同一
//}
@see Hash#compare_by_identity?... -
Hash
# compare _ by _ identity? -> bool (21313.0) -
ハッシュがキーの一致判定をオブジェクトの同一性を用いて行っているならば真を返します。
...ハッシュがキーの一致判定をオブジェクトの同一性を用いて行っているならば真を返します。
//emlist[例][ruby]{
h1 = {}
p h1.compare_by_identity? #=> false
h1.compare_by_identity
p h1.compare_by_identity? #=> true
//}
@see Hash#compare_by_identity... -
Array
# hash -> Integer (18362.0) -
自身のハッシュ値を整数で返します。ハッシュ値は自身の各要素のハッシュ値から 計算されます。Array#eql? で比較して等しい配列同士は同じハッシュ値を返します。
...ら
計算されます。Array#eql? で比較して等しい配列同士は同じハッシュ値を返します。
//emlist[例][ruby]{
a = ["a", "b", 1]
a.hash #=> 321
b = a.dup
b.hash #=> 321
["a", 1, "b"].hash #=> 491
["a", 1.0, "b"].hash #=> 466227
//}... -
Hash
# to _ h {|key , value| block } -> Hash (15537.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
# transform _ keys(hash) -> Hash (15464.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_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
# default -> object | nil (15455.0) -
ハッシュのデフォルト値を返します。
...l になることに注意してください。この場合、ハッシュのデフォルト値に
ついて調べるには 2 番目の形式か Hash#default_proc を使ってください。
2 番目の形式はハッシュがデフォルト値としてブロックを持つ場合に、
self と引......emlist[例][ruby]{
h = Hash.new("default")
p h.default #=> "default"
p h.default(:some) #=> "default"
p h #=>{}
h = Hash.new{|hash, key| hash[key] ="default" }
p h.default #=> nil
p h.default(:some) #=> "default"
p h #=> {:some=>"default"}
h = Hash.new
p h.default......#=> nil
p h.default(:some) #=> nil
p h #=> {}
//}
@see Hash#default=, Hash#default_proc... -
Hash
# shift -> [object , object] | nil (15437.0) -
ハッシュからキーが追加された順で先頭の要素をひとつ取り除き、 [key, value]という配列として返します。
...う配列として返します。
shiftは破壊的メソッドです。selfは要素を取り除かれた残りのハッシュに変更されます。
Ruby 3.2以前は、ハッシュが空の場合、デフォルト値(Hash#defaultまたはHash#default_procのブロックの値か、どちら......list[例][ruby]{
h = {:ab => "some" , :cd => "all"}
p h.shift #=> [:ab, "some"]
p h.shift #=> [:cd, "all"]
p h #=> {}
p h.shift #=> nil
h1 = Hash.new("default value")
p h1 #=> {}
p h1.shift #=> "default va......lue"
h2 = Hash.new {|*arg| arg}
p h2 #=> {}
p h2.shift #=> [{}, nil]
//}
@see Array#shift...