Ruby Marshaling

From the doc: Module: Marshal (Ruby 2.0.0)

(a) In normal use, marshaling can only load data written with the same
major version number and an equal or lower minor version number.

(b) If Ruby’s “verbose” flag is set (normally using -d, -v, -w, or
–verbose) the major and minor numbers must match exactly.

Can anyone give me simple examples for the above two points ?

Thanks

What didn’t you understand, and what are you trying to ask? What are
you looking for in examples? What specifics are you focusing on?

The documentation is clear enough about the versioning rules, with
their example, provided you understand enough fundamentals.

str = Marshal.dump(“foo”)
=> “\x04\bI”\bfoo\x06:\x06ET"

[str[0].ord, str[1].ord].join(".")
=> “4.8”

str[1] = “\x07”
=> “\a”

Marshal.load(str)
=> “foo”

str[1] = “\x09”
=> “\t”

Marshal.load(str)
TypeError: incompatible marshal file format (can’t be read)
format version 4.8 required; 4.9 given
from (irb):28:in load' from (irb):28 from /home/adam/.rvm/rubies/ruby-1.9.3-p286/bin/irb:16:in

Love U Ruby wrote in post #1104755:

From the doc: Module: Marshal (Ruby 2.0.0)

(a) In normal use, marshaling can only load data written with the same
major version number and an equal or lower minor version number.

  • By normal use what they tried to classify? And one example to see
    can only load data written with the same major version number and an
    equal or lower minor version number.

(b) If Ruby’s “verbose” flag is set (normally using -d, -v, -w, or
–verbose) the major and minor numbers must match exactly.

  • One example where major and minor number is equal.

What is the purpose of the comments regarding the interpreter. I think
they
may be misleading because if there’s one prominent thing -v prints is
the
version of Ruby!

What matters is Marshal::MAJOR_VERSION, and Marshal::MINOR_VERSION, and
they have been 4 and 8 for some time. They are still 4 and 8 in Ruby 2.