【发布时间】:2009-09-29 15:58:47
【问题描述】:
解析 YAML 文件后,我需要在 Ruby 数组中设置正确的值顺序。
我有一个简单的例子来说明我的问题:
x = "columns:\n col_1 : ~\n col_2 : ~\n col_3 : ~\n col4 : ~"
s = YAML::load(x)
控制台输出给出:
x = "列:\n col_1:~\n col_2:~\n col_3:~\n col4:~"
=> "列:\n col_1 : ~\n col_2 : ~\n col_3 : ~\n col4 : ~"
s = YAML::load(x)
=> {"columns"=>{"col_3"=>nil, "col4"=>nil, "col_1"=>nil, "col_2"=>nil}}
“columns”数组的顺序与输入数据中的顺序不同:(
【问题讨论】:
标签: ruby-on-rails ruby yaml