From: Robert Klemme Date: 2004-03-11T21:04:42+09:00 Subject: Re: saving array "gabriele renzi" schrieb im Newsbeitrag news:c30v401l703lrie4ogcjbsa5rvmir30v3v@4ax.com... > il 10 Mar 2004 12:36:16 -0800, mopthisandthat@hotmail.com (Phidippus) > ha scritto:: > > >After I do bunch of computations and create a huge array with bunch of > >numbers, I like to use the already-computed array in another program > >rather than re-computing it each time I run the program. How can I > >save the array object in one program and read it from another program > >in ruby? > > $irb > irb(main):001:0> Marshal.dump([1,2,3],open('ary.dat','w+')) > => # > irb(main):002:0> exit You should rather do Marshal.dump([1,2,3],open('ary.dat','wb')).close() in order to properly close the array. But the block form is even better as it ensures closing of the file under all conditions (others posted this form already): File.open('ary.dat','wb') {|f| Marshal.dump([1,2,3],f) } Similar for reading. robert