As many thanks As possible to who crates D and UFCS feature

drug via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 12 05:56:50 PDT 2017


12.05.2017 14:58, k-five пишет:
> On Friday, 12 May 2017 at 11:41:57 UTC, cym13 wrote:
>> On Friday, 12 May 2017 at 11:10:01 UTC, k-five wrote:
> -------------------------------------------------------
>>
>> Shorter:
>>
>> void main( string[] args ){
>>     dirEntries( ".", SpanMode.depth, false )
>>          .filter!( file => !file.name.matchFirst( regex( args[ 1 ] )
>> ).empty() )
>>          .filter!( file => ( args[ 2 ] == "-f" || args[ 2 ] == "-d"  ?
>> ( args[ 2 ] == "-f" ? !file.isDir : !file.isFile ) : ( !file.isSymlink
>> ) ) )
>>      .map!( file => file.name )
>>      .each!(string item => writeln( item ));
>> }
>>
>> It's more memory efficient too because at no point the actual list is
>> stored.
> ---------------------------------------------------------
>
> Thanks and the correct syntax for each! is, passing a lambda. So the:
>>      .each!(string item => writeln( item ));
> is an error:
> temp.d(15): Error: found 'item' when expecting ')' following template
> argument list ...
>
> and should be:
> .each!( ( string item )  => writeln( item ) );

also .each!writeln should be possible


More information about the Digitalmars-d-learn mailing list