<div dir="ltr">I didn’t write the guidelines but i never really felt Array(repeating:count:) was weird, you have two arguments, they need to be distinguished, and repeating is actually shorter than repeatedValue.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 9, 2018 at 12:09 PM, Gaétan Zanella via swift-users <span dir="ltr"><<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><a href="https://swift.org/documentation/api-design-guidelines" target="_blank">Swift API Design Guide</a> says :<div><br></div><div>> The first argument to initializer and factory methods calls should not form a phrase starting with the base name</div><div><br></div><div>Specially, it advises us against writing things like :</div><div><br></div><div><div>> let foreground = Color(havingRGBValuesRed: 32, green: 64, andBlue: 128) <br></div><div>> let newPart = factory.makeWidget(<wbr>havingGearCount: 42, andSpindleCount: 14) <br></div><div>> let ref = Link(to: destination) </div></div><div><br></div><div>But in UIKit, the Swift Standard Library or in Foundation, we find code like :</div><div><br></div><div><div> struct Array<T> {</div><div> // ...<br> init(repeating repeatedValue: Array.Element, count: Int)<br> }</div><div><br></div><div> struct Data {</div><div> // ...</div><div> init(referencing reference: NSData)</div><div> }</div><div><br> class UIImage {</div><div> // …</div><div> init?(named name: String, in bundle: Bundle?, <wbr>compatibleWith traitCollection: <wbr>UITraitCollection?)<br> }</div><div><br></div><div>I understand that some UIKit methods inherit their ObjC declarations like <a href="https://developer.apple.com/documentation/uikit/uiimage/1624154-imagenamed?language=objc" target="_blank">imageNamed:inBundle:<wbr>compatibleWithTraitCollection:</a><wbr>.</div><div>But what about Foundation and the Swift Standard Library ?</div></div><div><br></div><div>I agree that the initializers respect the Swift fundamentals : clean, short, readable, and consistent.</div><div>But the guide seems to be clear about it : we should not write such things.</div><div><br></div><div>Could someone shed some light on this point for me ? The subtlety about it.</div></div><br>______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
<br></blockquote></div><br></div>