るりまサーチ (Ruby 2.6.0)

最速Rubyリファレンスマニュアル検索!
3件ヒット [1-3件を表示] (0.035秒)
トップページ > クラス:Hash[x] > ライブラリ:ビルトイン[x] > バージョン:2.6.0[x] > クエリ:Hash#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

キーワード

検索結果

Hash#to_h -> self | Hash (69010.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] } #...

Hash#to_h {|key, value| block } -> Hash (69010.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] } #...

Hash#to_hash -> self (9028.0)

self を返します。

...self を返します。

//emlist[例][ruby]{
hash
= {}
p hash.to_hash # => {}
p hash.to_hash == hash # => true
//}

@see Object#to_hash, Hash#to_h...