Ruby:Hash.keys和Hash.values方法返回的键/值的顺序是什么? [英] Ruby: What is the order of keys/values returned by Hash.keys and Hash.values methods?
本文介绍了Ruby:Hash.keys和Hash.values方法返回的键/值的顺序是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否将项目添加到Hash的顺序相同?
Is it the same order in which the items were added to the Hash ?
推荐答案
哈希枚举它们的值的顺序是相应的键被插入。
Cursory测试表明这确实适用于 Hash#keys
和 Hash#values
,尽管这些方法的相应文档似乎没有指定它。
Cursory tests suggest that this does indeed apply to both Hash#keys
and Hash#values
, although the corresponding documentation for those methods doesn't seem to specify it.
这篇关于Ruby:Hash.keys和Hash.values方法返回的键/值的顺序是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文