Why Array / Dict / Optional are not compound types in Swift?

178 Views Asked by At

From the documentation :

In addition to user-defined named types, the Swift standard library defines many commonly used named types, including those that represent arrays, dictionaries, and optional values.

[...]

There are two compound types: function types and tuple types.

Well... It seems clear that dictionaries, arrays and optionals are named types and not compound types.

I don't understand why they are not compound types while tuple and function types are. Because from my perspective all these types are host for other types.

So two solutions :

  • There's something about compound types I don't understand
  • There's something about tuple and function types that I don't understand
1

There are 1 best solutions below

4
On BEST ANSWER

The documentation clearly states that compound types are those which don't have a name. A tuple type and function types don't have names i.e when specifying these types in function signature or variable you don't say let a : Tuple or let f : function, instead you have to use their own specific notation to specify the types - let a: (Int, Int) or let f: (Int, Int) -> Int

Compound types doesn't have anything to do with "host for other types".