I have 3 lists: headlines, sub-headlines, and image\_urls.

Each list is an array, and each may contain 0 or more items.

I want to create a permutation of every combination in this format:

```
[
  {headline: X1, subheadline: Y1, image_url: Z1}
  {headline: X1, subheadline: Y2, image_url: Z1}
  {headline: X1, subheadline: Y3, image_url: Z1}
  {headline: X1, subheadline: Y1, image_url: Z2} 
  ...
]

```

The only thing is, for any missing items I want it to be an empty string `''`.

The "dumb" solution I first had was to do...

```
headlines.each do |headline|
  subheadlines.each do |subheadline|
    image_urls.each do |url|
      {headline: headline, subheadline: subheadline, image_url: url}
    end
  end
end

```

But the only problem is, if one of the inner arrays is empty, say `subheadline`, instead of appending blank and continuing to iterate it will just stop right there, and all permutations will not be processed.

What method or approach might help me here?

Thanks!