DEV Community

Tomopteris
Tomopteris

Posted on

Swift Lesson 19 Discussion

Why should you consider using an enum over using a String or an Int to identify options?

When you’re trying to define multiple values for one object, and make sure these values are assigned only to one thing, it’s cleaner, and faster than assigning an int, and a string to one thing. For example, if you’re trying to define a car you could use both ints and strings for it: name:string, year:int, make:string, cylinder:int, etc…

Top comments (0)