writing objects to files

R

Radu Spineanu

Hi

Is it possible to write a ruby object (like a hash for example) to a
file, and then read it and use it accordingly ?

Thanks,
Radu Spineanu
 
M

Marc Heiler

Let me followup:

When to use Marshal, when to use yaml?
Does one of the two have a big advantage over the other?
 
J

James Edward Gray II

Let me followup:

When to use Marshal, when to use yaml?
Does one of the two have a big advantage over the other?

Marshal is C pretty fast, but it writes binary files that are not
human readable. YAML is plain text, but not as zippy.

Hope that helps.

James Edward Gray II
 
H

Hal Fulton

Marc said:
Let me followup:

When to use Marshal, when to use yaml?
Does one of the two have a big advantage over the other?

YAML is human readable/editable.

Marshal is more compact.

That's about it.


Hal
 
F

F. Senault

Le 24 août 2006 à 04:20, James Edward Gray II a écrit :
Marshal is C pretty fast, but it writes binary files that are not
human readable. YAML is plain text, but not as zippy.

And Marshal is not guaranteed to produce files compatible between
different versions of Ruby, while YAML is.

Fred
 
D

David Vallner

F. Senault said:
Le 24 août 2006 à 04:20, James Edward Gray II a écrit :


And Marshal is not guaranteed to produce files compatible between
different versions of Ruby, while YAML is.

-And- the YAML format is actually an open specification, so you get the
added value of being able to read the same file in other programming
languages - I have mild doubts there are parsers for whatever Marshal
outputs for anything but Ruby.

David Vallner
 
W

William Crawford

Christian said:
Ironically, history says a different thing. :)

Just because something has always been compatible doesn't mean it always
will be. Since YAML is an open spec, and Ruby follows that spec, it is
guaranteed. Nobody makes any guarantees about Marshal. (It isn't
likely to change without good reason, I'm sure, but that's not a
guarantee.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,210
Messages
2,571,091
Members
47,692
Latest member
RolandRose

Latest Threads

Top