How can I marshal a hash with arrays?

Posted by tuner on Stack Overflow See other posts from Stack Overflow or by tuner
Published on 2010-03-31T11:15:52Z Indexed on 2010/03/31 11:33 UTC
Read the original article Hit count: 206

Filed under:
|

What should I do to marshal an hash of arrays? The following code only prints {}.

s = Hash.new
s.default = Array.new
s[0] << "Tigger"
s[7] << "Ruth"
s[7] << "Puuh"
data = Marshal.dump(s)
ls = Marshal.restore( data )
p ls

If the hash doesn't contain an array it is restored properly.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about serialization