shorter alternative of constructor with parameter

Suliman via Digitalmars-d digitalmars-d at puremagic.com
Sat Jun 21 10:17:56 PDT 2014


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?


More information about the Digitalmars-d mailing list