This page contains automated test results for code from O'Reilly's Ruby Cookbook. If this code looks interesting or useful, you might want to buy the whole book.
| Serializing Data With Marshal | ||
|---|---|---|
| Code | Expected | Actual |
Marshal.dump(10) |
"\004\010i\017" | "\004\010i\017" |
Marshal.dump('ten') |
"\004\010\"\010ten" | "\004\010\"\010ten" |
Marshal.dump('10') |
"\004\010\"\a10" | "\004\010\"\a10" |
Marshal.load(Marshal.dump(%w{Brush up your Shakespeare})) |
["Brush", "up", "your", "Shakespeare"] | ["Brush", "up", "your", "Shakespeare"] |
require 'set' Marshal.load(Marshal.dump(Set.new([1, 2, 3]))) |
#<Set: {1, 2, 3}> | #<Set: {1, 2, 3}> |
Marshal.dump(Set) |
"\004\010c\010Set" | "\004\010c\010Set" |
open('output', 'w') { |f| Marshal.dump(f) } |
TypeError: can't dump File ... |
TypeError: can't dump File from (irb):8:in `dump' from (irb):8 from (irb):8 |