On 25.06.2016 03:50, Sayth Renshaw wrote:
What is the best way when collecting data to create a has of hashes?
So say this was my expected result.
{ Id:123 { id:1, name:John},{id:2, name: Sarah}}
This is not a valid representation of a Hash. Which of these do you want?
irb(main):001:0> { 'Id:123' => [{id:1, name:'John'}, {id:2, name:'Sarah'}]}
{"Id:123"=>[{:id=>1, :name=>"John"}, {:id=>2, :name=>"Sarah"}]}
irb(main):002:0> { Id:123, members: [{id:1, name:'John'}, {id:2, name:'Sarah'}]}
{:Id=>123, :members=>[{:id=>1, :name=>"John"}, {:id=>2, :name=>"Sarah"}]}
...
So that I am saying Sarah and John are members of group id: 123.
That depends on your input and how you access it.
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)