From: Pit Capitain Date: 2002-08-23T22:03:29+09:00 Subject: Re: converting rows into structs On 23 Aug 2002, at 17:56, Eugene Scripnik wrote: > I have a methods that converts all DB rows into structs using Struct > class. First version was: > > # res - result objects from DB connector > def create_structs( res ) > row_class = Struct.new( 'SQLRow', *res.names ) > data = [] > res.each do |row| > data << row_class.new( row ) > end > data > end (...) > # it is due to redefinition of Struct::SQLRow methods > > I would like to rewrite method create_structs to avoid this problem. If you pass a name as the first parameter to Struct.new, those names have to be unique. You can solve your problem by passing nil as the first argument to Struct.new: > row_class = Struct.new( nil, *res.names ) I suppose you don't refer to the name "SQLRow" anywhere else in your program, do you? Regards, Pit