【发布时间】:2014-05-29 15:27:23
【问题描述】:
我正在从 YAML 文件加载配置。
我有一个看起来像这样的哈希:{:first=>{:abc=>[["one", "two", "three"]], :def => [["one", "two", "three"]]}, :second=>{:abc=>[["one", "two", "three"]]}}
但我想得到:
{:first=>{:abc=>["one", "two", "three"], :def => ["one", "two", "three"]}, :second=>{:abc=>["one", "two", "three"]}}
即展平末端阵列。 结构不会比此处显示的“更深”。
单行代码是首选。
【问题讨论】:
标签: ruby-on-rails ruby arrays hash flatten