Is it safe to use floats in YAML hashes with Ruby?

前提是你 提交于 2019-12-11 02:24:17

问题


If I have a YAML file like

--- 
2.1: my product version

without any quotation marks, Ruby will treat the 2.1 as a Float (at least under Syck - I'm not sure about Psych).

Are there any risks in using a Float as a hash's key, so long as all of the other occurences of the key are either from a YAML file or literals from Ruby?

来源:https://stackoverflow.com/questions/8708113/is-it-safe-to-use-floats-in-yaml-hashes-with-ruby

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!