- Home /
Use the word "new" or not (Performance)
Simple question: is it faster/better to use the word "new" while setting or declaring a variable ?? ex.
function Start () {
test = new Vector3(0.0.0);
}
or
function Start () {
test = Vector3(0.0.0);
}
Answer by Eric5h5 · Mar 30, 2014 at 08:59 PM
It's completely irrelevant since the exact same thing happens whether you use the "new" keyword or not.
Thnx for the response ! I am also honored that someone so famous as Eric answered :)
Answer by ava4414 · Mar 30, 2014 at 10:17 PM
if you are in C# you have to initialize all variables so you have to do ...= new ... because if you dont initialize it you wont be able to use it.
right, and it's not about if you have to initialize or not but if you have to use "new" or not. In C# there's no alternative and you have to use "new" when creating an "instance". In UnityScript "new" can be omitted.
Yes i was talking about Unityscript but your info was quite helpful too :D