るりまサーチ

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

別のキーワード

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

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

Object#hash -> Integer (24380.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 (24250.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 (21250.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 (21225.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 (21219.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...

絞り込み条件を変える

Module#ruby2_keywords(method_name, ...) -> nil (18479.0)

For the given method names, marks the method as passing keywords through a normal argument splat. This should only be called on methods that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the method such that if the method is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the method to other methods.

... the given method names, marks the method as passing keywords through
a normal argument splat. This should only be called on methods that
accept an argument splat (`*args`) but not explicit keywords or a
keyword splat. It marks the method such that if the method is called
with keyword arguments, t...
...al hash argument is marked with a special
flag such that if it is the final element of a normal argument splat to
another method call, and that method call does not include explicit
keywords or a keyword splat, the final element is interpreted as
keywords. In other words, keywords will be passed thr...
...h the method to
other methods.

T
his should only be used for methods that delegate keywords to another
method, and only for backwards compatibility with Ruby versions before
2.7.

T
his method will probably be removed at some point, as it exists only
for backwards compatibility. As it does not exist...

Array#hash -> Integer (18268.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 (15443.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
//}

ブロックを指定すると各ペアでブロックを呼び出し、
その結果をペアとして使います。
//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 (15370.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 (15361.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...

絞り込み条件を変える

<< 1 2 3 ... > >>