Is order of a Ruby hash literal guaranteed?

后端 未结 2 1730
迷失自我
迷失自我 2020-12-11 14:42

Ruby, since v1.9, supports a deterministic order when looping through a hash; entries added first will be returned first.

Does this apply to literals, i.e. will

2条回答
  •  温柔的废话
    2020-12-11 15:19

    From the documentation:

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

提交回复
热议问题