"false"}] How to...">

Add hash to array?

I have this hash:

{:residential=>"false"} 

But I need to make this an array element:

 [{:residential=>"false"}] 

How to do it?

+6
source share
2 answers
 my_array = [] my_array << {:residential => "false"} => [{:residential=>"false"}] 
+16
source

The code you already wrote should be fine.

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

Source: https://habr.com/ru/post/896229/


All Articles