title: Ruby convert array to nested hash
body: <p>I have the following:</p>
  
  <pre><code>value = 42  
  array = ["this","is","a","test"]
  </code></pre>
  
  <p>how can I convert that to get this</p>
  
  <pre><code>{ "this" =&gt; { "is" =&gt; { "a" =&gt; { "test" =&gt; 42 } } } }
  </code></pre>
  
  <p>the array is always flat. </p>
  
  <p>Thank you!</p>