OpenStruct class provided by the ostruct library makes it even easier. : OpenStruct « Class « Ruby






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

 








Related examples in the same category