- Joined
- Mar 11, 2017
- Messages
- 587
(question auto-solved at the end of the post. roflmao)
Starting to learn basic basics of vJass. Structs. Confusion arises.
from the tutorial: vJASS OOP Lesson
from: "this" keyword usage (various users)
hence my confusion upon reading the following inside an example taken from Structs for Dummies :
_________________
This answer is clear. the constructor in the last example just explicitly declares "this". (this question was really stupid) (to anyone in charge. Delete thread if appropriate. If not, keep it as a simulacrum to my bright intellect)
Starting to learn basic basics of vJass. Structs. Confusion arises.
from the tutorial: vJASS OOP Lesson
Static methods cannot use the this keyword like instance methods do
from: "this" keyword usage (various users)
in static methods this is not declared.
for static, you use thistype
Code:method hi takes integer i returns nothing set thistype .i = i endmethod
"this" returns the specific struct instance
"static methods" are a general struct method and does not run off a specific instance
So since you're trying to call a specific instance when there is none it would return an error..."
hence my confusion upon reading the following inside an example taken from Structs for Dummies :
this constructor is static. Is it fine for it to use the keyword this? If that is the case, why is the constructor allowed to use this, when other static methods usually aren't allowed to? What am I missing?Code:static method create takes real X, real Y, real Z returns Pos local Pos this = Pos.allocate ( ) set this .x = X set this .y = Y set this .z = Z return this endmethod
_________________
This answer is clear. the constructor in the last example just explicitly declares "this". (this question was really stupid) (to anyone in charge. Delete thread if appropriate. If not, keep it as a simulacrum to my bright intellect)
Last edited: