You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on an AssemblyScript application. The way the code is structured requires passing an instance of a class in the constructor of another class. For example:
class Something {
constructor(private context: MyContext) { }
testMethod(): void {
//Some logic which uses variables and methods from context class
let a: this.context.getSomething();
}
}
class MyContext {
//Is below a correct usage of 'this'?
somethingObj: Something = new Something(this);
myMethod(): void {
//Some logic which uses somethingObj
this.somethingObj.testMethod()
}
}
I'm able to build and run the code successfully. But, is the above field somethingObj in MyContext class correctly using 'this' keyword? Could this somehow lead to some runtime errors around out of bounds memory access?
The text was updated successfully, but these errors were encountered:
Question
I'm working on an AssemblyScript application. The way the code is structured requires passing an instance of a class in the constructor of another class. For example:
I'm able to build and run the code successfully. But, is the above field somethingObj in MyContext class correctly using 'this' keyword? Could this somehow lead to some runtime errors around out of bounds memory access?
The text was updated successfully, but these errors were encountered: