Dlang Features You Would Like To Share

Dukc via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 12 22:51:27 PDT 2017


On Wednesday, 12 April 2017 at 21:40:48 UTC, bluecat wrote:
> What are some features that you have discovered that you would 
> like to share with the community?

auto use(alias F, T)(T t){return F(t);}

void main()
{   import std.stdio;
     foreach(i; 1 .. 11)
     {   foreach(j; 1 .. 11) write((i * j).use!(x => x*x), " ");
         writeln;
     }
}

This way, you can avoid writing long expressions twice with UFCS.




More information about the Digitalmars-d mailing list