Swift Collection Types (Arrays, Sets, Dictionaries)

In swift, collections are used to store or hold collection of multiple values in one place. We have multiple type of collections available in swift programming language those are

 

  • Arrays
  • Sets
  • Dictionaries

Swift Array Collection Types

In swift arrays are used to store same type of multiple values in ordered manner. In an array we can store same value in multiple times at different positions based on our requirements.

 

Following is the simple pictorial representation of arrays in swift programming language.

 

Swift Array Collection Types with Examples

 

If you want to learn more about arrays in swift programming language, check Swift Arrays article.

Swift Set Collection Types

In swift sets are used to store same type of distinct values in unordered manner. We can use sets instead of arrays in case if we want to store only distinct values and we are not concerned about the order of items. 

 

Following is the simple pictorial representation of sets in swift programming language.

 

Swift Set Collection Types with Examples

 

If you want to learn more about sets in swift programming language, check Swift Sets article.

Swift Dictionary Collection Types

In swift dictionaries are used to store values with key-value pair association in unordered manner. In dictionaries we can store same type of keys and same type of values with no defined order. The keys in dictionaries must be unique and those will act as identifiers for the values in dictionaries.

 

We can use dictionaries in swift programming language whenever we want to get values based on key value.

 

Following is the simple pictorial representation of dictionaries in swift programming language.

 

Swift Dictionary Collection Types with Examples

 

If you want to learn more about dictionaries in swift programming language, check Swift Dictionaries article.

 
 

NEXT

Swift Arrays