[swift-users] Exclamation mark's in swift parameter listings?
jgroff at apple.com
Tue Jan 10 11:14:34 CST 2017
> On Jan 9, 2017, at 11:19 PM, Rien via swift-users <swift-users at swift.org> wrote:
> It means that a call to that function with an optional will unwrap the optional before it is used.
> That is quite neat when dealing with C-API’s because often you will receive a pointer from a C-function which is optional to account for the fact that it can be NULL (= nil).
> By using a forced unwrapped input parameter you are saved the trouble of unwrapping all these pointers when using them as input for other C-APIs.
> In short, it makes it easier to interface with C-API’s.
> Note that there is some under-the-hood magic going on because a C-pointer is an unboxed value, while a ‘normal’ optional is a boxed value.
Optionals are never boxed.
More information about the swift-users