Why "double declare" classes? (Lack of better terminology)

Started by
19 comments, last by brunopava 10 years, 4 months ago

I'll ilustrate with C#:


// Here you create a create a variable, but is empty or null.
GameObject myGameObj;

// Here you assign a instance to that variable, so that is no longer null.
myGameObj = new GameObject();

/**
  The code you posted is just and shortcut for doing what I did.
  The advantage? You can create multiple instances using a for and assign them to a list.
  Every time the "new" keyword is used, it means that a new object of that type is being created.
*/

This topic is closed to new replies.

Advertisement