1件ヒット
[1-1件を表示]
(0.038秒)
クラス
- Struct (1)
検索結果
-
Struct
. new(*args) {|subclass| block } -> Class (54892.0) -
Struct クラスに新しいサブクラスを作って、それを返します。
Struct クラスに新しいサブクラスを作って、それを返します。
サブクラスでは構造体のメンバに対するアクセスメソッドが定義されています。
//emlist[例][ruby]{
dog = Struct.new("Dog", :name, :age)
fred = dog.new("fred", 5)
fred.age = 6
printf "name:%s age:%d", fred.name, fred.age
#=> "name:fred age:6" を出力します
//}
実装の都合により、クラス名の省略は後づけの機能でした。
メンバ名に String を指定できるのは後方互換...