From: Einar Karttunen Date: 2002-05-20T20:38:03+09:00 Subject: Re: (newbie?) storing object in files On 20.05 20:29, matt wrote: > I'm looking for a way to write objects into files. It should be > simple. There is the File/IO::print method, but this calls the to_s > method of the object you pass to it, and you have the string in the > file. But I have not yet found anything to convert it back to an > object. It is very simple to do it in ruby, just use Marshal. you can read the documentation from http://www.rubycentral.com/ref/ref_m_marshal.html here is the example from the page: class Klass def initialize(str) @str = str end def sayHello @str end end o = Klass.new("hello\n") data = Marshal.dump(o) obj = Marshal.load(data) obj.sayHello -> "hello\n" - Einar Karttunen