digitalmars.D.learn - Transform static immutable string array to tuple.
- realhet (8/8) Feb 19 2023 Hello,
- ag0aep6g (2/7) Feb 19 2023 https://dlang.org/phobos/std_meta.html#aliasSeqOf
- realhet (7/7) Feb 19 2023 Awesome, Thank both of you!
- H. S. Teoh (7/18) Feb 19 2023 In situations like this it's often better to define your dats as an
Hello, Is there a better way to transform a string array to a tuple or to an AliasSeq? ``` mixin(customSyntaxPrefixes.format!`tuple(%(%s,%))`) ``` I'd like to use this as variable length arguments passed to the startsWith() std function (as multiple needles).
Feb 19 2023
On Sunday, 19 February 2023 at 11:08:34 UTC, realhet wrote:Is there a better way to transform a string array to a tuple or to an AliasSeq? ``` mixin(customSyntaxPrefixes.format!`tuple(%(%s,%))`) ```https://dlang.org/phobos/std_meta.html#aliasSeqOf
Feb 19 2023
Awesome, Thank both of you! ``` enum a = ["A", "B"]; writeln(a); writeln(aliasSeqOf!a); writeln([aliasSeqOf!a]); ```
Feb 19 2023
On Sun, Feb 19, 2023 at 11:08:34AM +0000, realhet via Digitalmars-d-learn wrote:Hello, Is there a better way to transform a string array to a tuple or to an AliasSeq? ``` mixin(customSyntaxPrefixes.format!`tuple(%(%s,%))`) ``` I'd like to use this as variable length arguments passed to the startsWith() std function (as multiple needles).In situations like this it's often better to define your dats as an AliasSeq to begin with, since it's easier to covert that to an array than the other way round. T -- I don't trust computers, I've spent too long programming to think that they can get anything right. -- James Miller
Feb 19 2023