Make function alias

vit vit at vit.vit
Mon Aug 20 13:28:34 UTC 2018


On Monday, 20 August 2018 at 13:22:02 UTC, Andrey wrote:
> On Monday, 20 August 2018 at 13:14:14 UTC, Andrey wrote:
> Mistake... this is:
>>static void log(bool newline = true)(string text)
>>{
>>    alias print(T...) = newline ? &writeln : &write;
>> 
>>    _file.print(text);
>>    text.print();
>>}

static void log(bool newline = true)(string text)
{
     static if(newline)alias print = writeln;
     else alias print = write;

     _file.print(text);
     text.print();
}



More information about the Digitalmars-d-learn mailing list