<div dir="ltr">I would prefer a label on the first parameter, since you&#39;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: </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 == </span><span style="font-family:Menlo;font-size:11px;color:rgb(112,61,170)">NSOnState</span><span style="font-family:Menlo;font-size:11px"> })</span></div></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> </div><div>    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>