Skip to content

Instantly share code, notes, and snippets.

@dgmcguire
Created August 7, 2014 23:08
Show Gist options
  • Save dgmcguire/c24951c036e5d34978f6 to your computer and use it in GitHub Desktop.
Save dgmcguire/c24951c036e5d34978f6 to your computer and use it in GitHub Desktop.
weird hash onto array behavior
s.each do |i|
i.bindings.each do |k,v|
hash = Hash[k.to_sym, v.to_s]
attrs.merge!(hash)
end
p attrs
container_array << attrs
p container_array
end
#p output=> {:uri=>"http://facade.mit.edu/dataset/test", :name=>"test", :description=>"", :path=>"project"}
[{:uri=>"http://facade.mit.edu/dataset/test", :name=>"test", :description=>"", :path=>"project"}]
{:uri=>"http://facade.mit.edu/dataset/new", :name=>"new", :description=>"", :path=>"project"}
[{:uri=>"http://facade.mit.edu/dataset/new", :name=>"new", :description=>"", :path=>"project"}, {:uri=>"http://facade.mit.edu/dataset/new", :name=>"new", :description=>"", :path=>"project"}]
#final array=> [{:uri=>"http://facade.mit.edu/dataset/new", :name=>"new", :description=>"", :path=>"project"}, {:uri=>"http://facade.mit.edu/dataset/new", :name=>"new", :description=>"", :path=>"project"}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment