Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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 .