From: lists Date: 2006-11-17T08:25:35+09:00 Subject: Re: struct with defaults? On Nov 16, 2006, at 12:30 PM, Giles Bowkett wrote: > is there an easy, elegant way to set up a Struct so it has defaults on > initialization? > > (besides def initialize?) > > -- > Giles Bowkett > http://www.gilesgoatboy.org > > Not an exact answer to your question, but would using OpenStruct fit the bill? #!/usr/bin/env ruby require 'ostruct' user = OpenStruct.new({:name => 'Bob', :uid => 1234}) p user.name p user.uid user.name = 'Fred' p user.name