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)}

Advertisements

1 Response to “ruby marshal example”


  1. 1 Dave M
    August 3, 2011 at 18:02

    Thanks for this. It’s exactly what I was looking for.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Blog Stats

  • 228,119 hits

%d bloggers like this: