Thread overview | |||||
---|---|---|---|---|---|
|
October 05, 2016 Convert type tuple to array? | ||||
---|---|---|---|---|
| ||||
Is there a way to convert something like AliasSeq!(int, int, int) to an int[] - the opposite of aliasSeqOf? |
October 05, 2016 Re: Convert type tuple to array? | ||||
---|---|---|---|---|
| ||||
Posted in reply to John C | On Wednesday, 5 October 2016 at 11:43:12 UTC, John C wrote:
> Is there a way to convert something like AliasSeq!(int, int, int) to an int[] - the opposite of aliasSeqOf?
If it is a legal array (matching types), just put [] around it.
int[] arr = [ AliasSeq!(1,2,3) ];
An AliasSeq is considered by the language to be basically the same as a comma-separated list... you can almost "copy/paste" it into any context where those are legal, including function calls and array literals.
|
October 05, 2016 Re: Convert type tuple to array? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Wednesday, 5 October 2016 at 11:46:14 UTC, Adam D. Ruppe wrote:
> On Wednesday, 5 October 2016 at 11:43:12 UTC, John C wrote:
>> Is there a way to convert something like AliasSeq!(int, int, int) to an int[] - the opposite of aliasSeqOf?
>
> If it is a legal array (matching types), just put [] around it.
>
>
> int[] arr = [ AliasSeq!(1,2,3) ];
>
>
> An AliasSeq is considered by the language to be basically the same as a comma-separated list... you can almost "copy/paste" it into any context where those are legal, including function calls and array literals.
Great to know!
|
Copyright © 1999-2021 by the D Language Foundation