Skip to content

Instantly share code, notes, and snippets.

@daviddavis
Created April 10, 2013 15:23
Show Gist options
  • Select an option

  • Save daviddavis/5355593 to your computer and use it in GitHub Desktop.

Select an option

Save daviddavis/5355593 to your computer and use it in GitHub Desktop.
update a nested hash
parameters = {:units => [
{
:name => "wat",
:blah => "ok"
},
{
:name => "foo",
:max_version => 2
}
]}
# here we go
parameters[:units].detect{|hsh| hsh[:name] == "foo"}.merge!(max_version: 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment