<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="">This only solves the problem if the target function has one argument. I don't think the problem is so broad that is requires a stdlib change.</div><div class=""><br class=""></div><div class="">I'm -1 on this for now.</div><br class=""><div class="">
<div style="color: rgb(0, 0, 0); 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;" class=""><font color="#929292" class=""><br class="Apple-interchange-newline">Pozdrawiam – Regards,</font></div><div style="color: rgb(0, 0, 0); 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;" class=""><font color="#929292" class="">Adrian Kashivskyy</font></div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">Wiadomość napisana przez Brian Pratt via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> w dniu 11.03.2016, o godz. 16:28:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">+1, feels like a no-brainer and is a nice low-impact change. <div class=""><br class=""></div><div class="">I like it.</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Mar 11, 2016 at 12:14 AM, Thorsten Seitz via swift-evolution <span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto" class=""><div class=""></div><div class="">+1</div><div class="">ifPresent is something I've used a lot in Java/Guava.</div><div class="">In Smalltalk we had at:ifPresent: for dictionary lookup which could then easily be simulated by lookup followed by ifPresent.</div><div class=""><br class=""></div><div class="">-Thorsten </div><div class=""><div class="h5"><div class=""><br class="">Am 10.03.2016 um 22:55 schrieb Lammert Westerhoff via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>>:<br class=""><br class=""></div><blockquote type="cite" class=""><div class="">Currently the Swift Optional doesn’t have an ifPresent function. <br class="">This function is much like the map function except that the passed in function always returns Void. Almost the same can be done with the mapfunction, however the map function gives a compiler warning if it's result is unused. Also a map function can be ambiguous when there are multiple functions with the same name. The ifPresent will always pick the right function; i.e. the one returning Void and therefore is not ambiguous .<br class=""><br class="">The ifPresent function is like the map function very powerful. Some examples of its usage:<br class=""><br class=""><div class="">let mapView: MKMapView = ... // some map view</div><div class="">let annotation: MKAnnotation? = ... // some optional annotation</div><div class="">annotation.ifPresent(mapView.addAnnotation)</div><br class="">I also wrote a Blog Post about this topic in which I present it as an extension of Optional with some more examples where I find it very useful: <a href="https://swiftforward.wordpress.com/2015/12/04/add-ifpresent-to-swift-optionals/" target="_blank" class="">https://swiftforward.wordpress.com/2015/12/04/add-ifpresent-to-swift-optionals/</a><div class=""><br class=""></div><div class="">The implementation can be as simple as following:</div><div class=""><br class="">public func ifPresent(@noescape f: (Wrapped) throws -> Void) rethrows {<br class=""> _ = try map(f)<br class="">}</div><div class=""><br class=""></div><div class="">—</div><div class="">Lammert Westerhoff</div></div></blockquote></div></div><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><span class=""><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></span></div></blockquote></div><br class="">_______________________________________________<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" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br class=""></div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>