るりまサーチ

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

別のキーワード

  1. _builtin hash
  2. hash []
  3. matrix hash
  4. dbm to_hash
  5. _builtin to_hash

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

Hash#to_h -> self | Hash (27369.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#to_h {|key, value| block } -> Hash (27369.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#to_h -> self | Hash (27349.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
//}...

Hash#to_hash -> self (21268.0)

self を返します。

...self を返します。

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

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

OpenStruct#to_h {|name, value| block } -> Hash (21216.0)

self を各要素の名前をキー(Symbol)、要素が値のハッシュに変換して返 します。

...t[例][ruby]{
require 'ostruct'
data = OpenStruct.new("country" => "Australia", :capital => "Canberra")
data.to_h # => {:country => "Australia", :capital => "Canberra" }
data.to_h {|name, value| [name.to_s, value.upcase] }
# => {"country" => "AUSTRALIA", "capital" => "CANBERRA" }
//}...

絞り込み条件を変える

OpenSSL::X509::Extension#to_h -> Hash (21203.0)

拡張領域の内容を、 { "oid" => 識別子(extnID), "value" => 値(extnValue), "critical" => 重要度(critical) } というハッシュで返します。

拡張領域の内容を、
{ "oid" => 識別子(extnID), "value" => 値(extnValue), "critical" => 重要度(critical) }
というハッシュで返します。

OpenStruct#to_h -> { Symbol => object } (21116.0)

self を各要素の名前をキー(Symbol)、要素が値のハッシュに変換して返 します。

...t[例][ruby]{
require 'ostruct'
data = OpenStruct.new("country" => "Australia", :capital => "Canberra")
data.to_h # => {:country => "Australia", :capital => "Canberra" }
data.to_h {|name, value| [name.to_s, value.upcase] }
# => {"country" => "AUSTRALIA", "capital" => "CANBERRA" }
//}...

Object#to_hash -> Hash (12331.0)

オブジェクトの Hash への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。

...オブジェクトの Hash への暗黙の変換が必要なときに内部で呼ばれます。
デフォルトでは定義されていません。

説明のためここに記載してありますが、
このメソッドは実際には Object クラスには定義されていません。
必要...
...すべての場面で代置可能であるような、
* ハッシュそのものとみなせるようなもの
という厳しいものになっています。

//emlist[][ruby]{
class Foo
def to_hash
{'as' => 24}
end
end

it = Foo.new
p
({:as => 12}.merge(it)) #=> {"as"=>24, :as=>12}
//}...

DBM#to_hash -> Hash (12315.0)

self をハッシュに変換して返します。

...self をハッシュに変換して返します。

require 'dbm'

db1 = DBM.open('aaa.db', 0666, DBM::NEWDB)
db1[:a] = 'aaa'
db1[:b] = 'bbbbbb'
p
db1.to_hash #=> {"a"=>"aaa", "b"=>"bbbbbb"}...

SDBM#to_hash -> Hash (12315.0)

self の各要素を格納したハッシュを返します。

...self の各要素を格納したハッシュを返します。

require 'sdbm'

db1 = SDBM.open('aaa.gdbm', 0666)
db1.clear
db1['a'] = 'aaa'
db1['b'] = 'bbb'
db1['c'] = 'ccc'

p
db1.to_hash #=> {"a"=>"aaa", "b"=>"bbb", "c"=>"ccc"}...

絞り込み条件を変える

Enumerable#map -> Enumerator (3125.0)

各要素に対してブロックを評価した結果を全て含む配列を返します。

...配列を返します。

ブロックを省略した場合は Enumerator を返します。

//emlist[例][ruby]{
# すべて 3 倍にした配列を返す
p
(1..3).map {|n| n * 3 } # => [3, 6, 9]
p
(1..3).collect { "cat" } # => ["cat", "cat", "cat"]
//}

@see Hash#to_h, Array#collect, Array#map...
<< 1 2 > >>