L
Lex Williams
I recently tried to learn to use Marshal with a simple script , but I
keep getting the following exception : x.rb:6:in `load': marshal data
too short (ArgumentError)
This is the script :
hsh = {:first => [1,2,3],:second => [4,5,6] }
File.open("saved.m","w").puts(Marshal.dump(hsh))
str = (File.open("saved.m").read)
hix = Marshal.load(str) # this appears to be the problem line
hix.each_key do |key|
puts "key : #{key}"
end
could anyone tell me what I'm doing wrong ?
keep getting the following exception : x.rb:6:in `load': marshal data
too short (ArgumentError)
This is the script :
hsh = {:first => [1,2,3],:second => [4,5,6] }
File.open("saved.m","w").puts(Marshal.dump(hsh))
str = (File.open("saved.m").read)
hix = Marshal.load(str) # this appears to be the problem line
hix.each_key do |key|
puts "key : #{key}"
end
could anyone tell me what I'm doing wrong ?