When working with by-value types that have constructors, such as structs or more complex stack primitive data types, the keyword local may be used:
var up : Real3 = local Real3(0.0, 1.0, 0.0); var stackStructInstance : CustomStruct = local CustomStruct();
The compiler will infer the use of local for by-value types:
// This is also valid. var up : Real3 = Real3(0.0, 1.0, 0.0); var stackStructInstance : CustomStruct = CustomStruct();
When working with Classes and Structs, references, or other or anything located on the heap with a constructor, use the new keyword:
var heapObject : CustomClass = new CustomClass(); var heapStructInstance : CustomStruct = new CustomStruct();
Once again the compiler will infer the use of new for by-ref types:
// This is also valid. var heapObject : CustomClass = CustomClass();
Since structs are by-value, in order to get a reference you must specify new.
// This does not compile var heapStructInstance : CustomStruct = CustomStruct();
The value being assigned to 'heapStructInstance' must be of type 'CustomStruct'. Its type is 'CustomStruct'.