如何在 Ruby 1.9 中比较两个文件?

发布于 2024-12-17 17:56:26 字数 227 浏览 4 评论 0原文

在 Ruby 1.8 中,我会从“ftools”调用 File.compare() “库可以轻松比较两个文件的内容。

然而,在 Ruby 1.9 中,“ftools”被“fileutils”取代,后者没有“compare”方法。等效的调用是什么?

In Ruby 1.8, I would call File.compare() from the "ftools" library to easily compare the contents of two files.

However, in Ruby 1.9, "ftools" is replaced by "fileutils", which doesn't have a "compare" method. What's the equivalent call?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冬天的雪花 2024-12-24 17:56:26

啊,该方法已重命名为 compare_file

还有一个别名“cmp ”在两个版本中。

Ahh, the method has been renamed to compare_file in FileUtils.

There's also an alias of "cmp" in both versions.

山有枢 2024-12-24 17:56:26

老问题,但我刚从谷歌来到这里。 identical? 适用于那些像我一样喜欢这种编码风格的人。

FileUtils.identical?(exp, act)

Old question, but I just got here from google. identical? is available for those who like me prefer that coding style.

FileUtils.identical?(exp, act)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文