<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>+1 for being able to use&nbsp;<span style="background-color: rgba(255, 255, 255, 0);"><span class="">cars</span><span class="">.</span><span class="">map</span><span class="">(</span><span class="">make)</span></span></div><div><br>Am 16.12.2015 um 16:23 schrieb Al Skipp via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt;:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><div><blockquote type="cite" class=""><div class="">On 16 Dec 2015, at 12:47, Sean Kosanovich via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">As a Groovy user, I really enjoy the shorthand Spread Operator over the Collect Closure (Map is the equivalent in Swift).</span><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Consider the following Swift code:</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(187, 44, 162);">struct</span><span class="Apple-converted-space">&nbsp;</span>Car {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(187, 44, 162);">let</span><span class="Apple-converted-space">&nbsp;</span>make:<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(112, 61, 170);">String</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(187, 44, 162);">let</span><span class="Apple-converted-space">&nbsp;</span>model:<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(112, 61, 170);">String</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">}</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(187, 44, 162);">let</span><span class="Apple-converted-space">&nbsp;</span>cars = [<span class="" style="color: rgb(79, 129, 135);">Car</span>(make:<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(209, 47, 27);">"Jeep"</span>, model:<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(209, 47, 27);">"Grand Cherokee"</span>),<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(79, 129, 135);">Car</span>(make:<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(209, 47, 27);">"Dodge"</span>, model:<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(209, 47, 27);">"Challenger"</span>)]</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(187, 44, 162);">let</span><span class="Apple-converted-space">&nbsp;</span>makes =<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(79, 129, 135);">cars</span>.<span class="" style="color: rgb(61, 29, 129);">map</span>() { $0.<span class="" style="color: rgb(79, 129, 135);">make</span><span class="Apple-converted-space">&nbsp;</span>}</div></div><div class="" style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px; font-size: 11px; font-family: Menlo;"><br class=""></div><div class="" style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp;</div><div class="" style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px; font-size: 11px; font-family: Menlo;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="">Now consider the same code using a Spread Operator:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(187, 44, 162);">let</span><span class="Apple-converted-space">&nbsp;</span>makes =<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(79, 129, 135);">cars</span>*.make</div></div></div></div></blockquote></div><br class=""><div class="">I think there is a tension in Swift between its object oriented nature and higher-order functions which leads to a lot of repetition of { $0.property }</div><div class=""><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(79, 129, 135);"><br class=""></span></div><div class="">In this example:</div><div class=""><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(79, 129, 135);">cars</span><span style="font-family: Menlo; font-size: 11px;" class="">.</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(61, 29, 129);">map</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;{ $0.</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(79, 129, 135);">make</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;}</span></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""><br class=""></span></div><div class=""><div class="">I’d like to write the following, but ‘make’ is a member, not a free function:</div></div><div class=""><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(79, 129, 135);">cars</span><span style="font-family: Menlo; font-size: 11px;" class="">.</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(61, 29, 129);">map</span><span class="" style="font-family: Menlo; font-size: 11px;">(</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(79, 129, 135);">make)</span></div><div class=""><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(79, 129, 135);"><br class=""></span></div><div class="">Is anyone else irked by the preponderance of { $0.property } in Swift (or is it just me being grumpy)? Not sure what the solution would be, but I can’t say I’m keen on the suggestion of:</div><div class=""><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(79, 129, 135);"><br class=""></span></div><div class=""><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(79, 129, 135);">cars</span><span style="font-family: Menlo; font-size: 11px;" class="">*.make</span></div><div class=""><br class=""></div><div class="">It’s too mysterious.</div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=1MXK54sosN3xru3iYcLt0oBZ2w20i49gyogXctgrspcJllYkMx2zN7jpkwwYKNnXX-2Bn4Zop4fyUSq-2BmcR1-2BstADLmxRTvdGJnYSdqjrHMuJPQSWvTkpp-2Fbabszc3XxeXOZe2TCHGOWaxQqjAz6K1bR-2BbpjgmAQO-2FWx4CP7hGaV82qcpm4KWYgAZdhh4NQibFDb31SeddZPTjuJHU4V7yYkDZSOV6X3-2FyH07kLksysLk-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;">

</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></body></html>