Data Types

Why are arrays, sets, dictionaries, and tuples considered “data types”? Aren’t they considered “collection” types or objects? Maybe my background in JavaScript is lending to my confusion.

1 Like

I could be wrong but the term data type feels more language-agnostic and common in theoretical/academic writing. The wikipedia entry is ok for this (

I do not write serious swift, but I have written enough so that I can answer you. In all programing languages, including swift, there are different types of data types: Integers, Characters, Strings, Booleans, and others including dates, times, and countless more. These do belong into pre-written objects, especially if it is of the latter group. Arrays and sets are storing multiple variables, so that also requires an object to work. Furthermore, these are built-in, so they are data types.

Does this answer your question?

So, an array is considered a data type in itself (which also houses a sequence of data types of the same type)? Each data type is essentially its own object, yeah?

Yes and Yes. An array is totally unique from any other data types, yet is still considered one. According to this wiki article, Data types must be able to be defined in a variable, must be technology-neutral, and must have certain things that can be done with only that data type (eg Int-can be stored, it is not imposing on memory, and only ints can do math). Arrays can be stored into variables, It doesn’t take a lot of space to store arrays, and certain methods are only possible with arrays (.forEach, .join, .pop, etc). Arrays are data types, but they store other data types.

A lot to take in, but I think this should answer this question