Are tuples supported? · Issue #1425 · AssemblyScript/assemblyscript · GitHub
Skip to content

Are tuples supported? #1425

Closed
Closed

Description

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?

Activity

  1. MaxGraey commented on Aug 4, 2020

    @MaxGraey
    Member

    No, tuples not supported yet.

    Are there any workarounds?

    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 };
  2. MaxGraey commented on Aug 4, 2020

    @MaxGraey
    Member

    Sure, but for efficiently implement tuples / records we waiting wide support for multi-values

  3. ghost closed this as completedon Aug 4, 2020
  4. trusktr commented on Jun 5, 2022

    @trusktr
    Member

    array destructuring will be so so useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions