From: James Edward Gray II Date: 2007-02-17T12:00:00+09:00 Subject: Re: interesting usages of Struct? On Feb 16, 2007, at 7:30 PM, Joe at CodeGear wrote: > One use case that came to mind was for managing CSV files (esp. w/ > headers). You could create a Struct for the file, using the header > row from the file, passing a block to the new method to add a method > to initialize it based on an array (as returned from the csv reader). I really like the way you think: #!/usr/bin/env ruby -w require "rubygems" require "faster_csv" require "pp" Name = Struct.new(:first, :last) names = [Name.new("James", "Gray"), Name.new("Joe")] csv = FCSV.dump(names) puts <> CSV # >> === # >> class,Name # >> first=,last= # >> James,Gray # >> Joe, # >> # >> Ruby # >> ==== # >> [#, # >> #] __END__ James Edward Gray II