Ruby:Hash.keys和Hash.values方法返回的键/值的顺序是什么?

前端之家收集整理的这篇文章主要介绍了Ruby:Hash.keys和Hash.values方法返回的键/值的顺序是什么?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
将项目添加到哈希中的顺序是否相同?

解决方法

the Ruby 1.9.2 documentation for the Hash class的顶部声明:

Hashes enumerate their values in the order that the corresponding keys were inserted.

粗略测试表明,这确实适用于Hash#键和Hash#值,尽管这些方法的相应文档似乎没有指定.

原文链接:https://www.f2er.com/ruby/273165.html

猜你在找的Ruby相关文章