CobraA1
Member
So, I'm working with the new structs in the beta, but the documentation is not quite clear it seems.
At first, it uses a notation like this:
So okay, you define a struct using colons and commas between the braces, makes sense.
But then when they introduce the "new" keyword, they switch over to an entirely different syntax to make function-like:
Are the two syntaxes interchangeable? Is wrapping a struct in a function the only way to create a new instance of the struct? Wait - are structs and functions just variations of the same thing in GML? What is that "static" keyword doing? Is is similar to "static" in other languages? Are we essentially overloading a function to make it work like a struct? Why exactly is a series of instructions being treated similar to a memory structure?
At first, it uses a notation like this:
GML:
mystruct = {
a : 20,
b : "Hello World"
};
But then when they introduce the "new" keyword, they switch over to an entirely different syntax to make function-like:
GML:
Vector2 = function(_x, _y) constructor
{
x = _x;
y = _y;
static Add = function( _other )
{
x += _other.x;
y += _other.y;
}
}