• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] My vJass noob question - use of the this keyword

Status
Not open for further replies.
Level 14
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
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 :
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 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?
_________________

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:
Status
Not open for further replies.
Top