Here is the code I'm writing:
func printType<T: Any>(one: T.Type) {
print(one)
}
func printType2<T: Any>(one: T.Type, name: String) {
print(one)
}
printType(Set<Int>)
printType2(Set<Int>.self, name: "name")
I wonder why it printType(Set<Int>)
might work. And printType2(Set<Int>.self, name: "name")
I can’t leave. To make it work.
Edit:
I want to know what rule implies when I can omit .self
. I tried to find it in the official Apple links, but could not.
Edit:
I am testing codes in Xcode version 7.1 (7B91b).
source
share