Any way to reproduce Dart style constructors?

Moritz Maxeiner via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 25 12:15:10 PDT 2017


On Thursday, 25 May 2017 at 19:09:06 UTC, ag0aep6g wrote:
> [...]
> 
> Also, simply instantiating a function template inside a class 
> doesn't result in a method. If it did, the function/method 
> should be able to access class members. But it can't:
>
> ----
> int ft()() { return age; } /* Error: undefined identifier age */
> class Person
> {
>     int age = 42;
>     alias method = ft!(); /* error instantiating */
> }
> ----

Ok, you are right. Open a bug report?


More information about the Digitalmars-d-learn mailing list