我有这个哈希:
{
:items => {
:"cust.category" => "Jackets,Belts & Buttons",
:"items.receive_dt" => "2 years",
:"prdcts.brand" => "Armani"
}
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试更改此哈希使其变为->
{
:items => ["cust.category=Jackets,Belts & Buttons",
"items.receive_dt=2 years",
"prdcts.brand=Armani"]
}
Run Code Online (Sandbox Code Playgroud)
我尝试了几件事,但无法正确处理
h = {
:items=>{
:"cust.category"=>"Jackets,Belts & Buttons",
:"items.receive_dt"=>"2 years",
:"prdcts.brand"=>"Armani"
}
Run Code Online (Sandbox Code Playgroud)
h.transform_values { |g| g.map { |a| a.join('=') } }
#=> {:items=>["cust.category=Jackets,Belts & Buttons",
# "items.receive_dt=2 years",
# "prdcts.brand=Armani"]
# }
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
49 次 |
| 最近记录: |