multiple assignment
Assigning multiple variables at once.
ex;
a,b = [1,0],[2,4]
print(a[1] + b[0])
(for microscript).
Assigning multiple variables at once.
ex;
a,b = [1,0],[2,4]
print(a[1] + b[0])
(for microscript).
That will set them to the same value, but I think @gurg0 is looking for something like destructuring in JavaScript.
yeah, im looking to assign multiple variables with different values in a single statement.
If you really need destructuring now you can wrap some code in JavaScript.
For example like this
// javascript
function Build( data ) {
return new global[ data[0] ]( ...data[ 1 ] )
}
Give a specific example of what you need, maybe it can be done in JavaScript or wrapped in JavaScript.
I think destructuring won't be added to MicroScript because it's complicated and would slow down the code execution.
There could be a compilation step that converts code like this:
local [a, b] = some_function()
Into this:
local a = 0
local b = 0
if true then
local temp = some_function()
a = temp[0]
b = temp[1]
end
That would also allow other compiled features like type annotations and JSX-style HTML, but also introduce the problem of source maps. Or maybe microScript could implement syntax extensions, but that seems like a complex task.