るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

検索結果

Hash#to_h -> self | Hash (18314.0)

self を返します。Hash クラスのサブクラスから呼び出した場合は self を Hash オブジェクトに変換します。

...
self
を返します。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.class # => MyHash
p my_hash.to_h.class # => Hash
//}

ブロックを指定すると各ペアでブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
hash = { "a" => 97, "b" => 98 }
hash.to_h {|key, value| [key.upc...
...ase, value-32] } # => {"A"=>65, "B"=>66}
//}

@
see Enumerable#map...

Hash#to_h {|key, value| block } -> Hash (18214.0)

self を返します。Hash クラスのサブクラスから呼び出した場合は self を Hash オブジェクトに変換します。

...
self
を返します。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.class # => MyHash
p my_hash.to_h.class # => Hash
//}

ブロックを指定すると各ペアでブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
hash = { "a" => 97, "b" => 98 }
hash.to_h {|key, value| [key.upc...
...ase, value-32] } # => {"A"=>65, "B"=>66}
//}

@
see Enumerable#map...