On Wed, Oct 30, 2013 at 4:11 PM, Chuck N. <lists / ruby-forum.com> wrote:
> Hello I'm trying to learn ruby, and I have a question, how can I restore
> a file marshall. That is to say retrieve the original file. Thank you in
> advance, ruby is the first programming laguage I try to 'learn, so
> please give me a clear answer . I'm French sorry for my bad english

irb(main):004:0> x = rand(1000).to_s
=> "662"
irb(main):005:0> File.open("data.bin", "wb") {|io| Marshal.dump(x, io)}
=> #<File:data.bin (closed)>
irb(main):006:0> y = File.open("data.bin", "rb") {|io| Marshal.load(io)}
=> "662"
irb(main):007:0> x.equal? y
=> false
irb(main):008:0> x.object_id
=> 12886726380
irb(main):009:0> y.object_id
=> 12886713020

In this example "x" is just a sample value - could be any object.

Kind regards

rober


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/