[英]How to write Ruby hash with list keys in YAML?
說我有:
h = {}
h[["one", "two"]] = "three"
# h = {["one", "two"]=>"three"}
如何在YAML中表示上述哈希,以便YAML.load_file('that_file')
正確加載h
哈希?
您可以使用to_yaml
方法預覽:
h = {}
h[["one", "two"]] = "three"
h.to_yaml
# => "---\n? - one\n - two\n: three\n"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.