Let's remove the comments for a more visually fair comparison:
class Person {
String name;
Person(this.name);
}
vs
class Person(val name: String)
Ok, you save a line. I don't think that's a big deal. Also, the Dart version is very clear about what's a field or not. The first example I found of Scala classes on their site is this:
class Point(xc: Int, yc: Int) {
var x: Int = xc
var y: Int = yc
def move(dx: Int, dy: Int) {
x = x + dx
y = y + dy
}
override def toString(): String = "(" + x + ", " + y + ")";
}
With text that says `x` and `y` are the fields. What about `xc` and `yc`, I thought those were the fields?
Another thing I like about Dart is that the possible variations on the constructors fall into place, consistently:
No constructor args:
class Person {
String name;
}
Optional constructor args:
class Person {
String name;
Person({this.name});
}
Super call:
class Person extends Animal {
String name;
Person(this.name) : super() ;
}
The short Scala form may do that as well for all I know,