From: Gavin Sinclair Date: 2004-02-19T21:50:59+09:00 Subject: PATCH: OpenStruct#initialize to yield self This is a common approach I use to object initialization; I don't know about other people. Thought it was worth mentioning it here. It allows code like the following: record = OpenStruct.new do |r| r.name = "John Smith" r.age = 70 r.pension = 300 end Cheers, Gavin Index: ostruct.rb =================================================================== RCS file: /src/ruby/lib/ostruct.rb,v retrieving revision 1.8 diff -u -r1.8 ostruct.rb --- ostruct.rb 25 Sep 2003 00:03:11 -0000 1.8 +++ ostruct.rb 19 Feb 2004 12:46:18 -0000 @@ -16,6 +16,7 @@ @table[k.to_sym] = v end end + yield self if block_given? end def method_missing(mid, *args)