Building multidimensional array in Ruby
<p>I am trying to build a multidimensional array from two arrays. The use case is to build a dynamic menu.</p>

<p><code>Array #1</code> contains the titles for the menu where any title prefixed with <code>--</code> will be a 'main' title and any title prefixed with <code>-</code> will be a sub for the previous 'main' title.</p>

<p>For instance, if we have a hypothetical scenario like:</p>

<pre><code>--Home
--About
-Our Philosophy
-The Company
--Careers
-Job List
-Apply
--Contact
</code></pre>

<p><code>Array #2</code> contains the links for each menu item.</p>

<p>The first step was to combine both arrays into a hash by doing <code>combined = Hash[titles.zip(links)</code>.</p>

<p>How would I build it so that I can then loop over and build the menu dynamically?</p>

<p>Looking for a final similar structure to this (unless there's another suggested way):</p>

<pre><code>['Home' =&gt; 'http://stackoverflow.com/'],
['About' =&gt; 'http://stackoverflow.com/',
  [
    'Our Philosophy' =&gt; 'http://stackoverflow.com/',
    'The Company' =&gt; 'http://stackoverflow.com/'
  ]
]
etc...
</code></pre>

<p>If someone could explain how to then iterate over it, that would be awesome.</p>