Created
December 29, 2014 20:32
-
-
Save neonichu/e764ad902caead0176f9 to your computer and use it in GitHub Desktop.
WTF Swift generics?
This file contains hidden or 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
#!/usr/bin/env xcrun swift | |
import Foundation | |
class Base { | |
} | |
class Sub : Base { | |
} | |
func create<T : Base>() -> T { | |
println("param is: " + NSStringFromClass(T)) | |
return T() | |
} | |
let o1: Sub = create() | |
println("result is: " + NSStringFromClass(o1.dynamicType)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FWIW
correctly leads to