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

Reply via email to