<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Jens,<div class=""><br class=""></div><div class="">While I’m not familiar with the integer API in the standard library, structs and enums certainly can have convenience initializers. They must delegate to another initializer (either convenience or designated) rather than initializing the fields of the type one by one.</div><div class=""><br class=""></div><div class="">Slava</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 18, 2017, at 6:46 AM, Jens Persson via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Start a command line project in Xcode 9 beta 3 and copy paste this single line of code into main.swift</div><div class=""><br class=""></div><div class=""><div class="">let _ = UInt8.init(extendingOrTruncating: UInt64(123456))</div></div><div class=""><br class=""></div><div class="">Now look at Quick Help while placing the cursor on `init` and then on `extendingOrTruncating`.</div><div class=""><br class=""></div><div class="">Note that (and how) the documentation for the initializer differs depending on where you place the cursor.</div><div class=""><br class=""></div><div class="">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?</div><div class=""><br class=""></div><div class="">Even the official documentation for this and several other initializer like eg:</div><div class=""><a href="https://developer.apple.com/documentation/swift/int/2885075-init" class="">https://developer.apple.com/documentation/swift/int/2885075-init</a></div><div class="">clearly shows convenience initializers in structs.</div><div class=""><br class=""></div><div class="">By the way, .init(extendingOrTruncating:) doesn't show in the list of completions for "UInt8.init" but it does for "UInt8(".</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Can anyone explain what's going on?</div><div class=""><br class=""></div><div class="">Are these known issues that will go away in time for Xcode 9 GM?</div><div class=""><br class=""></div><div class="">/Jens</div><div class=""><br class=""></div></div>
_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></div></body></html>