1件ヒット
[1-1件を表示]
(0.230秒)
検索結果
先頭1件
-
Struct
# to _ h -> Hash (78385.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 の下位クラスを作成する点に
注意してください。...