Ruby/Class/nested classes
Материал из Wiki.crossplatform.ru
(Различия между версиями)
ViGOur (Обсуждение | вклад) м (1 версия: Импорт выборки материалов по Ruby) |
Текущая версия на 17:55, 13 сентября 2010
Access inner classes
class Drawing def Drawing.give_me_a_circle Circle.new end class Line end class Circle def what_am_i "This is a circle" end end end a = Drawing.give_me_a_circle puts a.what_am_i a = Drawing::Circle.new puts a.what_am_i a = Circle.new puts a.what_am_i
Place classes within other classes. These are called nested classes.
class Drawing class Line end class Circle end end