Conversation
…building new axes
…vertical and horizontal plots
|
Not yet ready |
|
|
||
| get falseIndicesArray(): boolean[] { return new Array(this.nSamples).fill(false) } | ||
|
|
||
| get offset_factor(): Vertex { return this._offset_factor ?? new Vertex(0.035, 0.07) } |
There was a problem hiding this comment.
Are these getters and setters necessary ?
There was a problem hiding this comment.
Yes they are since default values are not the same in parent and children
There was a problem hiding this comment.
Why can't the children just overwrite the default value to its own ?
There was a problem hiding this comment.
I am also questioning about that.
But what is clear is that you cannot expect this to work as expected:
class Parent {
attribute: type = X;
constructor() {
this.function(attribute)
}
}
class Children extends Parent {
attribute: type = Y;
constructor() {
super()
}
}
Here, the used value of attribute in children when running the constructor (which is what you want to do) will be X and not Y; because at this moment in the run of constructor, you are still in Parent class, although you are creating a Children instance.
To avoid this behavior, the Internet gives us the above trick.
There was a problem hiding this comment.
There was a problem hiding this comment.
Ok, I think this case made me understand what is the difference between inside/outside attribute assignment in js, which was not clear at all to me before.
They are actually not equivalent, after all. I think on the other side, that they are a bit similar to python's class attribute vs attribute, even if they are not the same.
Considering this thread, class fields (outside the constructor), are called after the constructor which leads to the shown behavior.
Actually, the prop attribute in our test case, is not static nor a class field, its a plain "instance attribute". In this case, I think we should then use the constructor syntax, even if its a bit more cumbersome (still less cumbersome than getters/setters, which usage is unclear) :
Uh oh!
There was an error while loading. Please reload this page.