<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div><br></div><div>Am 18.02.2016 um 20:36 schrieb Trent Nadeau via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt;:<br><br></div><blockquote type="cite"><div><div dir="ltr">I would prefer a label on the first parameter, since you're not finding the NSButton type but instead elements having the type of NSButton.<div><br></div><div><span style="font-family:Menlo;font-size:11px">subviews.find(havingType:&nbsp;</span><span style="font-family:Menlo;font-size:11px;color:rgb(112,61,170)">NSButton</span><span style="font-family:Menlo;font-size:11px">.</span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">self</span><span style="font-family:Menlo;font-size:11px">, matching: { $0.state ==&nbsp;</span><span style="font-family:Menlo;font-size:11px;color:rgb(112,61,170)">NSOnState</span><span style="font-family:Menlo;font-size:11px">&nbsp;})</span></div></div></div></blockquote><div><br></div>To comply with the guidelines I would expect a phrase like<div><br></div><div><div dir="ltr"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">subviews.findElement(havingType:&nbsp;NSButton.self, matching: { $0.state ==&nbsp;NSOnState&nbsp;})</span></font></div></div><div dir="ltr"><span style="background-color: rgba(255, 255, 255, 0);">subviews.find(instanceOf:&nbsp;NSButton.self, matching: { $0.state ==&nbsp;NSOnState&nbsp;})</span></div><div dir="ltr"><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div dir="ltr"><span style="background-color: rgba(255, 255, 255, 0);">-Thorsten&nbsp;</span></div><div><br><blockquote type="cite"><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 18, 2016 at 4:37 AM, Marco Masser via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</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"><br><div><span class=""><div><blockquote type="cite"><div>On 2016-02-18, at 00:46, Kevin Ballard via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br><div><div><div>Alternatively you can write<br></div><div>&nbsp;</div><div>&nbsp; &nbsp; subviews.lazy.flatMap({ $0 as? NSButton }).find({ $0.state == NSOnState })</div></div></div></blockquote><br></div></span><div>Just to reiterate my point: I very much prefer the version without any casts. I just think this is much clearer and doesn’t put the burden of thinking about accidental memory and speed overhead (when forgetting the “lazy”) on the caller every time:</div></div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span>subviews.find(</span><span style="color:#703daa">NSButton</span><span>.</span><span style="color:#bb2ca2">self</span><span>, matching: { $0.state == </span><span style="color:#703daa">NSOnState</span><span> })</span></div></div><div><br></div><div>Also, there’s the goal of Swift being easy to learn. Which line do you think is easier to explain to newcomers?</div></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Trent Nadeau</div>
</div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></div></body></html>