Ruby/Class/OpenStruct

Материал из Wiki.crossplatform.ru

(Различия между версиями)
Перейти к: навигация, поиск

Версия 17:10, 26 мая 2010

OpenStruct class provided by the ostruct library makes it even easier.

# Create data objects without specifying the attributes
# Create attributes on the fly:
 
require "ostruct"
person = OpenStruct.new
person.name = "Tom"
person.age = 25