Marshall and StringIO objects

rubyists-

does it not make sense that this should work?

~ > irb -r stringio
irb(main):001:0> Marshal.dump ‘foobar’, StringIO.new
TypeError: instance of IO needed
from (irb):1:in `dump’
from (irb):1

-a

···

Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ara.t.howard@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
~ > ruby -e ‘p % ^) .intern’
====================================

“ahoward” ahoward@fsl.noaa.gov wrote in message

does it not make sense that this should work?

~ > irb -r stringio
irb(main):001:0> Marshal.dump ‘foobar’, StringIO.new
TypeError: instance of IO needed
from (irb):1:in `dump’
from (irb):1

C:>irb -r stringio
irb(main):001:0> sio = Marshal.dump(‘foobar’,StringIO.new)
=> #StringIO:0x27c7a10
irb(main):002:0> Marshal.load(sio)
EOFError: End of file reached
from (irb):2:in `load’
from (irb):2
irb(main):003:0> quit

C:>irb -v
irb 0.9(02/07/03)

C:>ruby -v
ruby 1.8.0 (2003-05-26) [i386-mswin32]

“Shashank Date” sdate@everestkc.net wrote in message

C:>irb -r stringio
irb(main):001:0> sio = Marshal.dump(‘foobar’,StringIO.new)
=> #StringIO:0x27c7a10
irb(main):002:0> Marshal.load(sio)
EOFError: End of file reached
from (irb):2:in `load’
from (irb):2
irb(main):003:0> quit

Oops … sorry, copied the wrong example. Here is the correct one:

C:>irb -r stringio
irb(main):001:0> sio = Marshal.dump(‘foobar’,StringIO.new)
=> #StringIO:0x27c7a10
irb(main):002:0> p sio
#StringIO:0x27c7a10
=> nil
irb(main):003:0> sio.rewind
=> 0
irb(main):004:0> puts Marshal.load(sio)
foobar
=> nil
irb(main):005:0> quit

ahhh… i tried 1.6 w/shim, not 1.8. thanks!

-a

···

On Fri, 30 May 2003, Shashank Date wrote:

Oops … sorry, copied the wrong example. Here is the correct one:

C:>irb -r stringio
irb(main):001:0> sio = Marshal.dump(‘foobar’,StringIO.new)
=> #StringIO:0x27c7a10
irb(main):002:0> p sio
#StringIO:0x27c7a10
=> nil
irb(main):003:0> sio.rewind
=> 0
irb(main):004:0> puts Marshal.load(sio)
foobar
=> nil
irb(main):005:0> quit

Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ara.t.howard@noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
~ > ruby -e ‘p % ^) .intern’
====================================