How to use Namespaces in Swift?

后端 未结 8 1977
Happy的楠姐
Happy的楠姐 2020-11-28 01:53

The documentation only mentions nested types, but it\'s not clear if they can be used as namespaces. I haven\'t found any explicit mentioning of namespaces.

8条回答
  •  悲&欢浪女
    2020-11-28 02:25

    Swift uses modules much like in python (see here and here) and as @Kevin Sylvestre suggested you can also use the nested types as namespaces.

    And to extend the answer from @Daniel A. White, in WWDC they were talking about the modules in swift.

    Also here is explained:

    Inferred types make code cleaner and less prone to mistakes, while modules eliminate headers and provide namespaces.

提交回复
热议问题