Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Swift Enums and Structs Enums What is an Enum?

Difference between an enum and a dictionary?

Enums seem very similar to an array and/or dictionary. What is the difference? What are the use cases?

1 Answer

Stone Preston
Stone Preston
42,016 Points

arrays and dictionaries are data structures for storing collections of values whereas enumerations are a way for you to store related values as a type itself

from the Swift eBook

Swift provides two collection types, known as arrays and dictionaries, for storing collections of values. Arrays store ordered lists of values of the same type. Dictionaries store unordered collections of values of the same type, which can be referenced and looked up through a unique identifier (also known as a key).

An enumeration defines a common type for a group of related values and enables you to work with those values in a type-safe way within your code.

Thanks Stone Preston .