るりまサーチ

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

別のキーワード

  1. etc sc_xopen_enh_i18n
  2. rsa n
  3. rsa n=
  4. pop n_mails
  5. openssl n

キーワード

検索結果

<< 1 2 3 ... > >>

Hash#hash -> Integer (27314.0)

自身が保持するキーと値のハッシュ値を元にして算出した整数を返します。 自身が保持するキーや値が変化すればこのメソッドが返す値も変化します。

...自身が保持するキーと値のハッシュ値を元にして算出した整数を返します。
自身が保持するキーや値が変化すればこのメソッドが返す値も変化します。

//emlist[例][ruby]{
a = {}
p a.hash #=> 0
a[1] = :x
p a.hash #=> 329543
//}...

String#hash -> Integer (24326.0)

self のハッシュ値を返します。 eql? で等しい文字列は、常にハッシュ値も等しくなります。

...self のハッシュ値を返します。
eql? で等しい文字列は、常にハッシュ値も等しくなります。

//emlist[例][ruby]{
"test".hash # => 4038258770210371295
("te" + "st").hash == "test".hash # => true
//}

@see Hash...

Range#hash -> Integer (24314.0)

始端と終端のハッシュ値と Range#exclude_end? の値からハッシュ値を計算して整数として返します。

...始端と終端のハッシュ値と Range#exclude_end? の値からハッシュ値を計算して整数として返します。

//emlist[例][ruby]{
p (1..2).hash # => 5646
p (1...2).hash # => 16782863
//}...

Rational#hash -> Integer (24308.0)

自身のハッシュ値を返します。

...自身のハッシュ値を返します。

@return ハッシュ値を返します。


@see Object#hash...

Enumerator::ArithmeticSequence#hash -> Integer (24302.0)

自身のハッシュ値を返します。

...自身のハッシュ値を返します。

begin, end, step, exclude_end? が等しい Enumerable::ArithmeticSequence は
同じハッシュ値を返します。...

絞り込み条件を変える

OpenStruct#hash -> Integer (24302.0)

self のハッシュ値を返します。

self のハッシュ値を返します。

Hash#transform_keys(hash) -> Hash (21428.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#transform_keys -> Enumerator (21328.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#transform_keys {|key| ... } -> Hash (21328.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!...

Array#hash -> Integer (21326.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#invert -> Hash (21326.0)

値からキーへのハッシュを作成して返します。

...st[例][ruby]{
h = { "a" => 0, "b" => 100, "c" => 200, "d" => 300, "e" => 300 }
p h.invert #=> {0=>"a", 100=>"b", 200=>"c", 300=>"e"}
//}

=== 参考
値が重複していたときに備えて、変換後の値を配列として保持するには、次のようにします。

//emlist[][ruby]{
de...
...f safe_invert(orig_hash)
orig_hash.each_key.group_by do |key|
orig_hash[key]
end
end
p safe_invert({"a"=>1, "b"=>1, "c"=>3}) # => {1=>["a", "b"], 3=>["c"]}
//}

@see Hash#key...

Hash#transform_keys! -> Enumerator (21326.0)

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

...@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_keys!(hash) -> self (21326.0)

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

...@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_keys -> Enumerator (21320.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!...
<< 1 2 3 ... > >>