• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Structs - correct GML

jerob1995

Member
I am just curious if a struct needs a semi-colon ";" after the last curly bracket? The documentation example code uses it sometimes but not others and I was just wondering if one way is more correct?


GML:
// this
velocity = {
    x : 0,
    y : 0
};

// or this?
velocity = {
    x : 0,
    y : 0
}
 

TsukaYuriko

☄️
Forum Staff
Moderator
Keep in mind that this line is really just a variable assignment with the value being a struct, and it's no different from how it usually works in this regard. Much like most of GML, a semicolon is not strictly required, but recommended as a good practice because other languages may require it.
 

kburkhart84

Firehammer Games
In GML, the semi-colon is generally optional(though I don't like it). It is similar to the end of a line of code, not required, though better in general if you use them as a habit.
 
Top