I have a structure like this:
{:foo => ['foo1', 'foo2'], :bar => ['bar1']}
Which I would like to have transformed into:
[[:foo, "foo1"], [:foo, "foo2"], [:bar, "bar1"]]
My current solution is imperative:
result = []
h.each do |k,v|
v.each do |value|
result << [k, value]
end
end
While this works, I am certain that there is a much more elegant way to write this, but I can't figure it out. I would like to know what a function-oriented solution would look like?