Can this be done? Defining type as in this Scala sample code

drug drug2004 at bk.ru
Mon Feb 26 16:53:39 UTC 2018


you can do something like this (https://run.dlang.io/is/RYR5Dm):
```
import std.algorithm : sum;
import std.range : only;
import std.stdio : writeln;
import std.typecons : tuple;

void main()
{
     {
         auto list = tuple(1, 2.4, 5);
         auto sum = list.expand.only.sum;
         writeln(sum);
     }

     {
         // do not compile
         /*
         auto list = tuple(1, 2.4, 5, "123");
         auto sum = list.expand.only.sum;
         writeln(sum);
         */
     }
}
```


More information about the Digitalmars-d mailing list