shorter alternative of constructor with parameter
bearophile via Digitalmars-d
digitalmars-d at puremagic.com
Sat Jun 21 10:41:28 PDT 2014
Suliman:
> // Shorter alternative
> class Person {
> String name;
>
> // parameters prefixed by 'this.' will assign to
> // instance variables automatically
> Person(this.name);
> }
>
> it's there any DIP for adding this future to D?
This was already discussed once or more in past. Take a look in
Bugzilla, there is an ER. I think with some improvements this
idea is a good thing for D.
An even shorter syntax:
class Person {
this(const this.name) {}
}
Bye,
bearophile
More information about the Digitalmars-d
mailing list