objcio / functional-swift

Issue repository for the Functional Swift book
http://www.objc.io/books/fpinswift
927 stars 133 forks source link

Workaround for qsort intermediate let #134

Closed alessandro-martin closed 6 years ago

alessandro-martin commented 6 years ago

As stated in the book, because of https://bugs.swift.org/browse/SR-1914, we can't simply do: return qsort(lesser) + [pivot] + qsort(greater) but what about: return qsort(lesser) + Array(arrayLiteral: pivot) + qsort(greater) and getting rid of the intermediate let?

chriseidhof commented 6 years ago

That would work, but it's also pretty ugly! (Not your mistake, Swift's mistake). We'll revisit the example for the next update!