Learning swift for iOS and macOS development. I was creating a closure to sort strings reversely this way:
let reversed = names.sorted(by: { (s1: String, s2: String) -> Bool in return s1 > s2 })
The sort() function simply takes a function that takes 2 strings and returns a bool. What I didn't realize is the the "operator >" that I'm using on the closure is itself a function that takes 2 strings and return a bool.
So that chunk above can be reduced to:
So that chunk above can be reduced to:
let reversed = names.sorted(by: >)