Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 将两个泛型类型作为函数参数传递_Swift - Fatal编程技术网

Swift 将两个泛型类型作为函数参数传递

Swift 将两个泛型类型作为函数参数传递,swift,Swift,作为示例函数给出: func sample<Z: Equatable, X: IntegerType>(from: Z.Type, to: X.Type) { print("HELLO") } sample(String, to: Int) func示例(从:Z.Type到:X.Type){ 打印(“你好”) } 示例(字符串,至:Int) 我在调用中得到以下错误缺少参数“to”的参数 我遗漏了什么吗?看来这样行得通 sample(String.self, to: In

作为示例函数给出:

func sample<Z: Equatable, X: IntegerType>(from: Z.Type, to: X.Type) {
    print("HELLO")
}

sample(String, to: Int)
func示例(从:Z.Type到:X.Type){
打印(“你好”)
}
示例(字符串,至:Int)
我在调用中得到以下错误
缺少参数“to”的参数


我遗漏了什么吗?

看来这样行得通

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

看来这会有用的

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

是的,也许XCode auto建议too@redent84,不,不建议是的,可能是XCode auto建议too@redent84,不,我不这么认为