Is there a more elegant way to do this in D?

ddcovery antoniocabreraperez at gmail.com
Fri Apr 9 14:24:58 UTC 2021


On Thursday, 8 April 2021 at 04:02:26 UTC, Ali Çehreli wrote:
> On 4/7/21 8:57 PM, Brad wrote:
>
>>      auto a = [1,0,1,1,1,0,1,0,1,1,1,1,0];
>
>> I want to come out of this with a string that looks like this: 
>> 1011101011110
>
> Me, me, me, me! :)
>
> import std;
> void main()
> {
>   auto a = [1,0,1,1,1,0,1,0,1,1,1,1,0];
>
>   string s = format!"%-(%s%)"(a);
>   writeln(s);
> }
>
> Ali

I'm really addict to the new shortened methods syntax

import std;
void main() =>
     [1,0,1,1,1,0,1,0,1,1,1,0].
     format!"%-(%s%)".
     writeln;


More information about the Digitalmars-d-learn mailing list