Wouldn’t you use less code in the end by just using a string?
ie…
if (state == State.Alive) vs if (state == “Alive”)
What are the benefits of using an enum?
Wouldn’t you use less code in the end by just using a string?
ie…
if (state == State.Alive) vs if (state == “Alive”)
What are the benefits of using an enum?
enums are handled very efficiently, where as computers handle strings worst of all.
enums do not have to be exclusive either, such as you can have player, enemy, questgiver, alive, lootable etc…
Also its less likely to typeo
something can therefore be enemy and aiive or enemy and lootable, or an enemy and a questgiver… or go from enemy and alive to enemy and lootable… If you ever played a muck/mush type game, this would be exactly how they define flags in the game (Chownable, Dark, Pickupable etc)
Ok, that makes good sense to me. Thanks!
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.