I'm currently doing the below, calling it via this line: var newNumbers = GetNumberClass( 5 );
class NumberClass
{
var num1 = 2;
var num2 = 3;
}
function GetNumberClass ( add : int )
{
var n = new NumberClass();
n.num1 += add;
n.num2 += add + 10;
return n;
}
I feel like I might have once read a better way to do this, but can't remember exactly how or the terminology, but does something along these lines exist?
class NumberClass
{
var num1 = 2;
var num2 = 3;
function GetNumberClass ( add : int )
{
num1 += add;
num2 += add + 10;
return NumberClass;
}
}
My examples are in Unityscript but I would understand an answer in either that or C#.