What's happening behind the scene with implicitly unwrapped option when it's being evaluated?

12 views
Skip to first unread message

Boon

unread,
Jun 17, 2015, 11:51:58 AM6/17/15
to swift-l...@googlegroups.com

What's happening behind the scene with implicitly unwrapped option?
Does the compile perform the unboxing of ImplicitlyUnwrappedOptional behind the scene, right before you use the value in an expression?  Since ImplicitlyUnwrappedOptional is a struct, can the same operation be done in Swift?

Brent Royal-Gordon

unread,
Jun 18, 2015, 3:47:14 PM6/18/15
to Boon, swift-l...@googlegroups.com
Implicitly unwrapped optionals are treated specially by the compiler; there's no way for us to write something similar.

(For that matter, regular optionals have some special behavior too; the automatic conversion of Foo to Optional<Foo> is unique to optionals. But they're far less magical than implicitly unwrapped optionals.)
On Wed, Jun 17, 2015 at 8:51 AM Boon <bo...@nanaimostudio.com> wrote:

What's happening behind the scene with implicitly unwrapped option?
Does the compile perform the unboxing of ImplicitlyUnwrappedOptional behind the scene, right before you use the value in an expression?  Since ImplicitlyUnwrappedOptional is a struct, can the same operation be done in Swift?

--
You received this message because you are subscribed to the Google Groups "Swift Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swift-languag...@googlegroups.com.
To post to this group, send email to swift-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/7ef04ad1-d9be-4918-997b-d98c711a90fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages