I installed AssemblyScript and found out that tuple support is missing.
Here is my code:
const data: [i32, f64] = [2, 9.9];
Are there any workarounds?
No, tuples not supported yet.
Any of next variants:
const data = [2, 9.9]; // deduced as `data: f64[]` // more efficient fixed sized arrays: const data: StaticArray<f64> = [2, 9.9];
If you still need tuple which hold different types and can't unify it like showed above better just boxing into a class:
class Tuple2<T, U> { _0: T; _1: U }; const data: Tuple2<i32, f64> = { _0: 2, _1: 9.9 };
Sure, but for efficiently implement tuples / records we waiting wide support for multi-values
array destructuring will be so so useful!
Activity
MaxGraey commentedon Aug 4, 2020
No, tuples not supported yet.
Any of next variants:
If you still need tuple which hold different types and can't unify it like showed above better just boxing into a class:
MaxGraey commentedon Aug 4, 2020
Sure, but for efficiently implement tuples / records we waiting wide support for multi-values
trusktr commentedon Jun 5, 2022
array destructuring will be so so useful!