A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.wikibooks.org/wiki/Ruby_Programming/Reference/Objects/Marshal below:

Ruby Programming/Reference/Objects/Marshal - Wikibooks, open books for an open world

From Wikibooks, open books for an open world

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4