传递了两个泛型类型作为函数参数
问题描述:
给出的作为样本功能:传递了两个泛型类型作为函数参数
func sample<Z: Equatable, X: IntegerType>(from: Z.Type, to: X.Type) {
print("HELLO")
}
sample(String, to: Int)
我收到以下错误Missing argument for parameter 'to' in call
我缺少的东西?
答
看起来这将工作
sample(String.self, to: Int.self)
是的,大概的XCode自动提示过 – redent84
@ redent84,没有不建议它 –