0

New to Dart, consider:

class Point {
  double x;
  double y;

  // Compiler throws error that values are not init
  Point(double x, double y) {
    this.x = x;
    this.y = y;
  }
}

class Point {
  double x;
  double y;
  // But this works
  Point(this.x, this.y);
}

Why is it the first constructor works but the second doesn't? Isn't the second constructor just the shorthand version of the first?

Kex
  • 7,245
  • 8
  • 48
  • 109

0 Answers0