るりまサーチ

最速Rubyリファレンスマニュアル検索!
34件ヒット [1-34件を表示] (0.027秒)
トップページ > クエリ:Enumerable#to_h[x]

別のキーワード

  1. << rexml::attribute#name
  2. add rexml::attribute#name
  3. handle_interrupt thread#raise
  4. service drb::extserv#stop_service
  5. inspect? irb::context#inspect_mode

ライブラリ

モジュール

キーワード

検索結果

Enumerable#to_h(*args) -> Hash (23000.0)

self を [key, value] のペアの配列として解析した結果を Hash にして 返します。

self を [key, value] のペアの配列として解析した結果を Hash にして
返します。

@param args each の呼び出し時に引数として渡されます。

//emlist[例][ruby]{
%i[hello world].each_with_index.to_h # => {:hello => 0, :world => 1}
//}
self を [key, value] のペアの配列として解析した結果を Hash にして
返します。

@param args each の呼び出し時に引数として渡されます。

//emlist[例][ruby]{
%i[hello world].each_with_index.to_h # => {:hello => 0, :world => 1}
//}

ブロックを指定すると各要素でブロックを呼び出し、
その結果をペアとして使います。

//emlist[ブロック付きの例][ruby]{
(1..5).to_h {|x| [x, x ** 2]} # => {1=>1, 2=>4, ...

Enumerable#to_h(*args) { ... } -> Hash (23000.0)

self を [key, value] のペアの配列として解析した結果を Hash にして 返します。

self を [key, value] のペアの配列として解析した結果を Hash にして
返します。

@param args each の呼び出し時に引数として渡されます。

//emlist[例][ruby]{
%i[hello world].each_with_index.to_h # => {:hello => 0, :world => 1}
//}

ブロックを指定すると各要素でブロックを呼び出し、
その結果をペアとして使います。

//emlist[ブロック付きの例][ruby]{
(1..5).to_h {|x| [x, x ** 2]} # => {1=>1, 2=>4, ...

NEWS for Ruby 2.1.0 (6.0)

NEWS for Ruby 2.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...inding#local_variable_get
* 追加: Binding#local_variable_set
* 追加: Binding#local_variable_defined?

* Enumerable
* 追加: Enumerable#to_h キーと値のペアのリストをハッシュに変換します。

* Exception
* 追加: Exception#cause 一つ前の例外を新...

NEWS for Ruby 2.6.0 (6.0)

NEWS for Ruby 2.6.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...順番にイテレートする
Enumerator::Chain オブジェクトを返します。 15144
* 変更されたメソッド
* Enumerable#to_h はブロックを受け取りキーと値のペアを新しいキーと値に変換できるようになりました。 15143
* 別名...