title: A better way to assign multiple return values to table keys in Lua
body: <p>Assume I have a function that returns multiple values.  I happen to be working with LÖVE's <a href="https://love2d.org/wiki/(Image):getDimensions" rel="nofollow noreferrer"><code>(Image):getDimensions</code></a>.  This returns two values, which I know to be <code>width,height</code>.  I want to assign them to a new table, as an array.  I would like named (string) keys.  So for instance, I would like to assign the return values of the <code>getDimensions()</code> function to a new table with keys <code>width</code> and <code>height</code>, respectively.</p>
  
  <p>I know the following works...</p>
  
  <pre><code>image = {}
  image.data = love.graphics.newImage('myimage.png')
  image.size = {}
  image.size.width, image.size.height = image.data:getDimensions()
  </code></pre>
  
  <p>I'm wondering if there is any sort of syntactic sugar I can use, or any use of standard library functions that will allow a syntax more along the lines of...</p>
  
  <pre><code>image.size = { width, height = image.data:getDimensions() }
  </code></pre>
  
  <p>I know the above line does not work, along with many variations I've tried, including various attempts to use <code>unpack()</code>.  I'm new to Lua (~2 days in now), so maybe there is another standard function or best practice that I'm unaware of that will associate a table of keys to an array-like table.  Thanks!</p>