Skip to Content

Ruby - Create an Array with a single Hash witout the curly braces

Posted on

Each time I want to create an array, which contains 1 array of Hash, I usualy write:

[{ name: 'Taylor', age: 36 }]

But we can do this:

[name: 'Taylor', age: 36]

The result for both of those will be:

[{:name=>"Taylor", :age=>36}]
comments powered by Disqus