Can I unpack several named fields from a table in lua by name? I know that I can use table.unpack to unpack the numbered fields from a table into separate variables and I also can extract just one named field from the table.
local a, b = table.unpack({1,2,3})
print(a, b) -- will print "1 2"
local t = {some=1, stuff=2}
local field = t.some
print(field) -- will print "1"
But I want to know if there is an equivalent to the following snipped in php
$x = ["a"=>1, "b"=>2, "c"=>3];
list("a"=>$a, "c"=>$c) = $x;
echo "$a $c"; // will print "1 3"
My use case is a require which returns a table with many named fields and I
am only interested in some. So currently I am doing
local a = require("file/where/I/just/need/one/field").the_field
local tmp = require("file/that/returns/table/with/many/fields")
local b, c = tmp.x, tmp.y
But I was wondering if I could do that second one on one line.