2016-04-14 223 views
0

給出的作爲樣本功能:傳遞了兩個泛型類型作爲函數參數

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

我缺少的東西?

回答

2

看起來這將工作

sample(String.self, to: Int.self) 
+0

是的,大概的XCode自動提示過 – redent84

+0

@ redent84,沒有不建議它 –