Hi,
I've written this to test the behaviours of tables in classes and their instances.
It seems that tables in a class are shared between all instances of that class.
Is this intended? Shouldn't each class instance contain it's own instance of the table?
Class instances seem to have their own instance of simple types, like integers.
class Object
{
Attributes = {};
}
class ChildObject extends Object
{
constructor()
{
Attribute["1"] <- 0;
}
}
print( ChildObject.Attributes );
//print( ChildObject.Attributes["1"] ); // 1) This results in AN ERROR HAS OCCURED [the index '1' does not exist]
local test = ChildObject();
print( test.Attributes ); // 2) This shows the same address as ChildObject.Attributes.
print( test.Attributes["1"] ); // 2) This is 0, as expected
// Change the instance's member.
test.Attributes["1"] = 1;
print( test.Attributes ); // 3) Still the same address as ChildObject.Attributes.
print( test.Attributes["1"] ); // 3) This is 1, as expected
print( ChildObject.Attributes );
print( ChildObject.Attributes["1"] ); // 4) But this is now also 1, when it should be 0
//local x = 1+1;
local test2 = ChildObject();
print( test2.Attributes ); // 5) This also shows the same address as ChildObject.Attributes.
print( test2.Attributes["1"] ); // 5) This shows 0, as if ChildObject.Attributes was reset
// Change the 2nd instance's member.
test2.Attributes["1"] = 2;
print( test.Attributes ); // 6) Still the same address as ChildObject.Attributes.
print( test.Attributes["1"] ); // 6) This now shows 2, when it should be 1
print( test2.Attributes ); // 7) Still the same address as ChildObject.Attributes.
print( test2.Attributes["1"] ); // 7) This shows 2, as expected
print( ChildObject.Attributes );
print( ChildObject.Attributes["1"] ); // 8) This now shows 2, when it should be 0