<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 24, 2016, at 7:07 AM, Jean-Denis Muys via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Alegreya-Regular; font-size: 15px; font-style: normal; font-variant-caps: 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="">However I was wondering if it was possible (preferable?) to do it in a more “functional” style.</span></div></blockquote><br class=""></div><div>Apple’s Foundation framework has Array.arrayByAddingObject (but not ByRemoving).</div><div><br class=""></div><div>However, this would not be preferable (at least in performance) due to all the copying. Performance of appending n items would be O(n^2), for instance, vs. O(n) for appending in-place.</div><div><br class=""></div><div>—Jens</div></body></html>