What should I do to marshal an hash of arrays?
The following code only prints {}
.
s = Hash.new
s.default = Array.new
s[0] <<
As you can't use Marshall.dump
on a Hash with a proc for the default element, you could use a slightly more roundabout way of appending to each Array instead of <<
:
s = Hash.new
s.default = []
s[0] += [ "Tigger" ]
s[7] += [ "Ruth" ]
s[7] += [ "Pooh" ]
data = Marshal.dump(s)
ls = Marshal.restore(data)
p ls