title: Convert Nested Array into Nested Hash in Ruby
body: <p>Without knowing the dimension of array, how do I convert an array to a nested hash?</p>
  
  <p>For example:</p>
  
  <pre><code>[["Message", "hello"]]
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>{{:message =&gt; "Hello"}}
  </code></pre>
  
  <p>Or:</p>
  
  <pre><code>[["Memory", [["Internal Memory", "32 GB"], ["Card Type", "MicroSD"]]]]
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>{{:memory =&gt; {:internal_memroy =&gt; "32 GB", :card_type =&gt; "MicroSD"}}}
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>[["Memory", [["Internal Memory", "32 GB"], ["Card Type", "MicroSD"]]], ["Size", [["Width", "12cm"], ["height", "20cm"]]]]
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>{ {:memory =&gt; {:internal_memroy =&gt; "32 GB", :card_type =&gt; "MicroSD"}, {:size =&gt; {:width =&gt; "12cm", :height =&gt; "20cm" } } }
  </code></pre>