I like D

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Tue Mar 24 13:19:01 PDT 2015


On 3/24/15 4:11 PM, Andrei Alexandrescu wrote:
> On 3/24/15 11:56 AM, "Jacques =?UTF-8?B?TcO8bGxlciI=?=
> <jacques.mueller at gmx.de>" wrote:
>> On Tuesday, 24 March 2015 at 13:09:21 UTC, Steven Schveighoffer wrote:
>>> New code:
>>>
>>> immutable nfields = header.count('\t');
>>> ...
>>> output.writeln(cycle("\t-").take(2 * nfields));
>>
>> output.writeln("\t-".repeat(nfields).join);
>
> output.writeln("\t-".repeat(nfields).joiner);
>

Yeah, I looked at repeat first, but it didn't do what I wanted (would 
only repeat a single element).

For some reason, this seems more complex to me. However, it does have 
the benefit of not needing the '2 *'. But I did not think of using 
joiner, nice solution!

-Steve


More information about the Digitalmars-d mailing list