Skip to content

Instantly share code, notes, and snippets.

@cassdeckard
Created May 11, 2015 21:00
Show Gist options
  • Select an option

  • Save cassdeckard/c18b1f24c7efb23735f2 to your computer and use it in GitHub Desktop.

Select an option

Save cassdeckard/c18b1f24c7efb23735f2 to your computer and use it in GitHub Desktop.
Swift can't decide if [String] is Equatable?
import XCTest
class GenericThing<T: Equatable> {
func foo(t: T) {
NSLog("foo \(t)")
}
}
func genericFunc<T: Equatable>(left: T, right: T) {
NSLog("\(left) == \(right) ?: \(left == right)")
}
class GenericThingTest {
// WHY DOES THIS NOT COMPILE?!?
//let testObject = GenericThing<[String]>()
func testThatShouldClearlyPass() {
// BUT THIS DOES???
genericFunc(["foo"], ["foo"])
XCTAssert(true)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment