Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Ruby Programming/Reference/Objects/Marshal

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Marshal The Marshal class is used for serializing and de-serializing objects to disk: ex serialized = Marshal.dump(['an', 'array', 'of', 'strings']) unserialized = Marshal.restore(serialized) With 1.9, each dump also includes an encoding, so you *must* use Marshal's stream read feature if you wish to read it from an IO object, like a file. a = File.open("serialized_data", "w") a.write Marshal.dump(33) b = File.open("serialized_data", "r") unserialized = Marshal.restore(b) b.close