Clue supports renameable destructuring - local {a => b} = t read as "assign t.a to local b" - but currently only identifier fields are allowed (names that can index tables through dot notation).
It would be nice if we can also use value types for the source field, similar to Lua letting you use any non-nil type as a table key.
local {[1] => a, [2] => b} = {"hello", "world"}
// -- now a is "hello" and b is "world"
local {[true] => c, ["string field"] => d} = {[true] = false, ["string field"] = "yes"}
// -- c is now false, d is now "yes"
Better too if the source key will support expressions in general
local {[4] => {[iter] => x, [iter+1] => y}} = points
// -- x would be the value of points[4][iter], y would be points[4][iter+1]
Additionally, a separate syntax for destructuring arrays sequential-index tables may be helpful too
local [x,y,z] = {1, 0, 64}
// -- x = 1, y = 0, z = 64
Clue supports renameable destructuring -
local {a => b} = tread as "assignt.atolocal b" - but currently only identifier fields are allowed (names that can index tables through dot notation).It would be nice if we can also use value types for the source field, similar to Lua letting you use any non-nil type as a table key.
Better too if the source key will support expressions in general
Additionally, a separate syntax for destructuring
arrayssequential-index tables may be helpful too