Any reason we can't consider a scala-like constructor?
```js
class Point(x, y) {
toString() {
return `(${this.x},${this.y})`
}
}
console.log(`??? ${new Point(1, 2)}`); // ??? 1,2
````
Doesn't conflict with existing syntax, it's clear, and you can still
shorthand most data-classes or structs to just:
```
class MyData(some, props, here) {}
```
I imagine this as the syntax:
```
class Point(x, y) { // implicits x, y as first two args of constru
constructor(a, b, c) {
this.z = a + b + c;
console.log(this.x, this.y, this.c); // values of: a, b, c
console.log(this.x === a, this.y === b); // true, true
}
}
```
And de-sugared:
```
class Point {
constructor(a, b, c) {
this.x = a;
this.y = b;
// rest of body
this.z = a + b + c;
}
}
```
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss