Archive for the 'serialization' Category

21
Apr
10

ruby marshal example


I can never remember the order of the parameters to Marshal, so here’s an example of using it:


#serialization
File.open("some.file","wb") do |file|
   Marshal.dump(object_to_serialize,file)
end

#loading
object = nil
File.open("some.file","rb") {|f| object = Marshal.load(f)}




Blog Stats

  • 215,481 hits