class foo {}
class FooAndData
{
FooAndData ( foo@ _foo )
{
@memberVar = _foo;
}
foo@ memberVar;
// todo: add more stuff
};
void main()
{
dictionary dict = { {'entry', foo()} }; // OK
dict['additionalEntry'] = foo(); // OK
@dict['additionalEntry'] = foo(); // OK
dictionary dict2 = { {'entry', FooAndData(null)} }; // OK
//dict2['additionalEntry'] = FooAndData(null); // "Failed in call to function 'CreateScriptObject' (Code: -6)"
@dict2['additionalEntry'] = FooAndData(null); // OK
}
I'm confused by the failure of the middle call in the second group. Why can I instantiate a parameter-less instance of foo and add it to the dictionary, but I cannot instantiate FooAndData(null) and add it to the dictionary? In my mind, the dictionary is logically storing object instances, not handles to object instances.