From: 520079130762-0001@... (Michael Neumann) Date: 2002-10-22T13:58:54+09:00 Subject: Re: XMLRPC and complex data structures On Mon, 2002-10-21 at 23:55, Daniel Berger wrote: > Just to see what would happen with regular Ruby structs (i.e. no extensions), I > tried adding this method to the xmlrpc server: > > # Return an array of structs > def get_aos > TestStruct = Struct.new("TestStruct",:name,:age) > dan = TestStruct.new("Dan",32) > joe = TestStruct.new("Joe",29) > a = [] > a.push(dan,joe) > return a > end Simply, don't use a constant: def get_aos testStruct = Struct.new("TestStruct",:name,:age) dan = testStruct.new("Dan",32) joe = testStruct.new("Joe",29) a = [] a.push(dan,joe) return a end You can also create the structs via Struct::TestStruct.new. > This caused a "dynamic constant assignment" error, and I could only get it to > work if I declared the struct type outside the class. Could dynamic struct > generation be the source of the problem? If so, why? This is not a problem, if you don't use constants. See above. Note that you can also move the struct definition outside the method: TestStruct = Struct.new("TestStruct",:name,:age) def get_aos dan = TestStruct.new("Dan",32) joe = TestStruct.new("Joe",29) a = [] a.push(dan,joe) return a end Regards, Michael