Last active
August 29, 2015 14:08
-
-
Save marcpalmer/b1fc694ce398c82e614f to your computer and use it in GitHub Desktop.
Obscure bug with > overloading with UIKit under iOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code fails to compile with iOS SDK 8.1 and Xcode 6.1 | |
import UIKit | |
let names = ["a","c","b"] | |
// This fails to compile on iOS targets | |
// It works if: | |
// a) you add "return" to the closure | |
// - or - | |
// b) you remove the UIKit import | |
var reversed = sorted(names) { $0 > $1 } | |
println(reversed) |
I think the problem is that there are declarations for:
func <(lhs: UnicodeScalar, rhs: UnicodeScalar) -> Bool
func <(lhs: UInt, rhs: UInt) -> Bool
func <(lhs: String.Index, rhs: String.Index) -> Bool
func <(lhs: String, rhs: String) -> Bool
...but no such overrides declared for >
Although this doesn't make sense to me, how adding "return" can fix the problem.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Notes: