ios - Implicitly Unwrapped Optional Types - Possible Typo? -


from swift programming language documentation:

implicitly unwrapped optional type

the swift language defines postfix ! syntactic sugar named type implicitlyunwrappedoptional, defined in swift standard library. in other words, following 2 declarations equivalent:

var implicitlyunwrappedstring: string! var implicitlyunwrappedstring: string! 

in both cases, variable implicitlyunwrappedstring declared have type of implicitly unwrapped optional string. note no whitespace may appear between type , !.

am missing something? both lines same me, why wouldn't 2 declarations equivalent?

yes, makes no sense. you'll find correct version in swift book:

in other words, following 2 declarations equivalent:

var​ ​implicitlyunwrappedstring​: ​string​! ​var​ ​implicitlyunwrappedstring​: ​implicitlyunwrappedoptional​<​string​> 

excerpt from: apple inc. “the swift programming language.” ibooks. https://itun.es/de/jeuh0.l


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -