Enum vs arrays

Haven’t really gone through this whole video yet, but thought I’d bring up something that was slightly confusing me.

We’re currently logging the current screen we’re on using enum Screen. So, my understanding is that we effectively defined Screen as a new variable type, and it can be one of three possible things, MainMenu, Password or Win. And we initialised a string variable called currentScreen to hold whatever Screen is at a given time.

So, is Screen not technically an array? Could we not have used the method for making an array in order to keep track of our current screen? What’s so important/significant/special about using enum to create it?

Hi @mysticjim,

So, is Screen not technically an array?

No.

Could we not have used the method for making an array in order to keep track of our current screen?

You could.

What’s so important/significant/special about using enum to create it?

Using an enum will allow you to specify which are valid options for selection, either in code, via Visual Studio’s Intellisense, or, if exposed to the Inspector for a designer to perhaps select from.

Hope the above is of use. :slight_smile:


See also;

2 Likes

Privacy & Terms