开发者

Add a hash to an array?

开发者 https://www.devze.com 2023-04-01 08:29 出处:网络
I\'ve currently got this hash: {:residential=>\"fal开发者_运维技巧se\"} But I need to make it an item of an array:

I've currently got this hash:

{:residential=>"fal开发者_运维技巧se"}

But I need to make it an item of an array:

[{:residential=>"false"}]

How do I do that?


my_array = []
my_array << {:residential => "false"}
=> [{:residential=>"false"}]


The code you've already written should be just fine.

>> x = [{:residental=>"false"}, {:residental=>"true"}]                  
=> [{:residental=>"false"}, {:residental=>"true"}]                      
>> x[0][:residental]                                                    
=> "false"
0

精彩评论

暂无评论...
验证码 换一张
取 消