小编Ani*_*Ani的帖子

在特定位置插入哈希条目

给出哈希:

{"set_filter"=>["0"], "test1"=>["=test1"], "test2"=>["=test2"]}
Run Code Online (Sandbox Code Playgroud)

如何在set_filter条目后添加新的键值对?预期的输出应该是这样的:

{
  "set_filter" => ["0"],
  "test3" => ["=test3"],
  "test1" => ["=test1"],
  "test2" => ["=test2"]
}
Run Code Online (Sandbox Code Playgroud)

我想在哈希中的某个位置插入一个新的键值对.

ruby hash

4
推荐指数
2
解决办法
1241
查看次数

标签 统计

hash ×1

ruby ×1