<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=""><div class="">Yes, I am proposing this be part of the standard library.</div><div class=""><br class=""></div><div class=""><div class="">Additional use cases that are possible in Groovy are using it for setting variables or calling methods, like the following (ignore the example of changing a car’s make doesn’t make much since):</div><div class=""><br class=""></div><div class="">cars*.make = “Chevrolet”</div><div class=""><br class=""></div><div class="">or </div><div class=""><br class=""></div><div class="">cars*.notifyOfLowFuel()</div></div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 16, 2015, at 10:14 AM, Matthew Johnson <<a href="mailto:matthew@anandabits.com" class="">matthew@anandabits.com</a>> 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; 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="">You can already define an infix operator that does this. Are you proposing one be in the standard library? I would be opposed to adding new syntax for this.</span><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: 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 class=""><blockquote type="cite" class=""><div class="">On Dec 16, 2015, at 6:47 AM, Sean Kosanovich via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">As a Groovy user, I really enjoy the shorthand Spread Operator over the Collect Closure (Map is the equivalent in Swift).<div class=""><br class=""></div><div class="">Consider the following Swift code:</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);">struct</span><span class="Apple-converted-space"> </span>Car {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="Apple-converted-space"> </span><span class="" style="color: rgb(187, 44, 162);">let</span><span class="Apple-converted-space"> </span>make:<span class="Apple-converted-space"> </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;"> <span class="Apple-converted-space"> </span><span class="" style="color: rgb(187, 44, 162);">let</span><span class="Apple-converted-space"> </span>model:<span class="Apple-converted-space"> </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"> </span>cars = [<span class="" style="color: rgb(79, 129, 135);">Car</span>(make:<span class="Apple-converted-space"> </span><span class="" style="color: rgb(209, 47, 27);">"Jeep"</span>, model:<span class="Apple-converted-space"> </span><span class="" style="color: rgb(209, 47, 27);">"Grand Cherokee"</span>),<span class="Apple-converted-space"> </span><span class="" style="color: rgb(79, 129, 135);">Car</span>(make:<span class="Apple-converted-space"> </span><span class="" style="color: rgb(209, 47, 27);">"Dodge"</span>, model:<span class="Apple-converted-space"> </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"> </span>makes =<span class="Apple-converted-space"> </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"> </span>}</div></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><br class=""></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;"><br class=""></div><div class=""><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"> </span>makes =<span class="Apple-converted-space"> </span><span class="" style="color: rgb(79, 129, 135);">cars</span>*.make</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">The other distinction in Groovy is that the Spread Operator is null safe, meaning it won’t throw a NPE if an element is null, whereas the Collect Closure would. So in Swift, I would propose the Spread Operator implicitly does this when operating on an array of Optionals:</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"> </span>makes =<span class="Apple-converted-space"> </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"> </span>}</div></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><br class=""></div></div><div class="" style="margin: 0px; line-height: normal;">Thanks!</div><div class="" style="margin: 0px; line-height: normal;">Sean</div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=eLFMrKDT8iBxZ-2Fbnk-2BZqvSchNN-2FvYXdceA0T7VxwkAfkeFtVq-2FDeSmmAYj-2BuVuR1g89wRc5MoRMEjEuWCtVc1QwaKyj4n0sOecI8nrdkYJAV7wj8DrW0zh8gjNR5Xa3hBTABQSPOR-2B-2BrDaS-2BXneVq8bIf45zTqzntJlv-2BFYQbFBD9ryWTPeXWhdkshOPQjNiOHFsqyVgPu-2FpJWvYdmLg6lxoJNhPb-2Frq1Qmn08Yfj7g-3D" alt="" width="1" height="1" border="0" class="" style="height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;"></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div></div></div></blockquote></div><br class=""></body></html>