shorter alternative of constructor with parameter
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jun 23 15:01:39 PDT 2014
On Mon, 23 Jun 2014 17:38:53 -0400, Grogan <Grogan at od.fr> wrote:
> On Saturday, 21 June 2014 at 17:17:57 UTC, Suliman wrote:
>> Dart and few others modern languages support short declaration
>> constructor with parameter:
>>
>> class Person {
>> String name;
>>
>> Person(String name) {
>> this.name = name;
>> }
>> }
>>
>> // 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?
>
> If name is a property with getter and/setter: stack overflow ;).
How so?
-Steve
More information about the Digitalmars-d
mailing list