Skip to content

Instantly share code, notes, and snippets.

@dasibre
Created March 4, 2016 15:54
Show Gist options
  • Select an option

  • Save dasibre/fd82884a8368790faa78 to your computer and use it in GitHub Desktop.

Select an option

Save dasibre/fd82884a8368790faa78 to your computer and use it in GitHub Desktop.
hash merge with block
ids = [%w(d b f a), %w(d c a)]
hash = {}
a.map do |list|
list.each_with_index do |v,idx|
h = {}
h[idx] = v
hash.merge!(h) do |_,left,right|
Array(left) + Array(right)
end
hash
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment