From: ts Date: 2008-03-27T23:34:32+09:00 Subject: Re: Marshal Clean Up Callback? Norman Elton wrote: > I know I can use marshal_dump and marshal_load, but then I've got to do > all the serialization myself. The Marshal class does a good job of this, > I just want to clean things up a bit before the Marshal code takes over. No, you don't need to make the serialization with marshal_load/marshal_dump, here an example vgs% cat b.rb #!/usr/bin/ruby require 'socket' class A def initialize @a = UDPSocket.new @b = {1 => 2} @c = [3, 4] end def marshal_dump [@b, @c] end def marshal_load(x) @a = UDPSocket.new @b, @c = x end end p Marshal.load(Marshal.dump(A.new)) vgs% vgs% ./b.rb #2}, @a=#> vgs% Guy Decoux