如何将Ruby数组存储到文件中? [英] how to store a Ruby array into a file?

查看:44
本文介绍了如何将Ruby数组存储到文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 Ruby 数组存储到文件中?

How to store a Ruby array into a file?

推荐答案

有多种方法可以将数组转储到磁盘.您需要决定是要以二进制格式还是以文本格式进行序列化.

There are multiple ways to dump an array to disk. You need to decide if you want to serialize in a binary format or in a text format.

对于二进制序列化,您可以查看 Marshal

For binary serialization you can look at Marshal

对于文本格式,您可以使用 jsonyaml, xml(带有 rexml, builder, ... ) , ...

For text format you can use json, yaml, xml (with rexml, builder, ... ) , ...

这篇关于如何将Ruby数组存储到文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆