代码之家  ›  专栏  ›  技术社区  ›  porton

如何在D中解压/解构数组?

  •  1
  • porton  · 技术社区  · 7 年前

    如何在D中解压/解构数组?

    [3,4,5] a , b , c )只有一项任务。

    我在D怎么做?

    2 回复  |  直到 7 年前
        1
  •  1
  •   Valmat    7 年前

    尝试 tie 从我的配音包 vest :

    import vest.utils: tie;
    int a,b,c;
    tie(a,b,c) = [1, 2, 2];
    

        2
  •  1
  •   porton    7 年前

    letassign.d https://bitbucket.org/infognition/dstuff/src 允许以下代码:

    int x, y, z;
    let (x,y,z) = [1,2,3];
    

    顺便说一下,这应该在标准D库中!