Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question
    
A quick Ctrl-F search of their iBook shows no instances of namespaces...so I'm going with no? –  Justin Niessner 20 hours ago
    
I don't know why this question is closed. I saw namespace on keynote at the left side of Swift icon, and I still cannot find any mention from the documentation... –  Eonil 11 hours ago
    
I couldn't find any information on this, Google led me to this question :). Perhaps one of the WWDC sessions will shed a bit more light on this. –  Zyphrax 8 hours ago
add comment

3 Answers

up vote 2 down vote accepted

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.

share|improve this answer
add comment

I believe this is achieved using:

struct Foo
{
    class Bar
    {
    }
}

Then it can be accessed using:

var dds = Foo.Bar();
share|improve this answer
add comment

It was announced in the keynote that it does support namespaces.

share|improve this answer
4  
How does it work? –  Kevin Sylvestre 17 hours ago
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.