るりまサーチ (Ruby 2.5.0)

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

別のキーワード

  1. _builtin to_s
  2. openssl to_der
  3. openssl to_s
  4. _builtin to_a
  5. openssl to_pem

ライブラリ

検索結果

Struct#to_h -> Hash (54325.0)

self のメンバ名(Symbol)と値の組を Hash にして返します。

...す。

//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_h
# => {:name=>"Joe Smith", :address=>"123 Maple, Anytown NC", :zip=>12345}
//}


[注意] 本メソッドの記述は Struct の下位クラスのインスタンス...
...に対して呼び
出す事を想定しています。Struct.new は Struct の下位クラスを作成する点に
注意してください。...