[swift-users] Convenience initializers in structs?

Jens Persson jens at bitcycle.com
Tue Jul 18 08:46:07 CDT 2017


Start a command line project in Xcode 9 beta 3 and copy paste this single
line of code into main.swift

let _ = UInt8.init(extendingOrTruncating: UInt64(123456))

Now look at Quick Help while placing the cursor on `init` and then on
`extendingOrTruncating`.

Note that (and how) the documentation for the initializer differs depending
on where you place the cursor.

If the cursor is on `init`, the initializer is shown to be a convenience(!)
initializer even though structs (such as UInt8) cannot have convenience
initializers, right?

Even the official documentation for this and several other initializer like
eg:
https://developer.apple.com/documentation/swift/int/2885075-init
clearly shows convenience initializers in structs.

By the way, .init(extendingOrTruncating:) doesn't show in the list of
completions for "UInt8.init" but it does for "UInt8(".


Can anyone explain what's going on?

Are these known issues that will go away in time for Xcode 9 GM?

/Jens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170718/b9d80c7b/attachment.html>


More information about the swift-users mailing list