ruby的序列化类是 Marshalclass Klass
def initialize(str)
@str = str
end
def say_hello
@str
end
end
o = Klass.new("hello\n")
data = Marshal.dump(o) 将o序列化
obj = Marshal.load(data) 反序列化获得o
obj.say_hello #=> "hello\n"
ruby的序列化类是 Marshalclass Klass
def initialize(str)
@str = str
end
def say_hello
@str
end
end
o = Klass.new("hello\n")
data = Marshal.dump(o) 将o序列化
obj = Marshal.load(data) 反序列化获得o
obj.say_hello #=> "hello\n"