元素未泛型的数组扩展

时间:2018-12-19 12:30:17

标签: swift

我想知道为什么编译

extension Array where Element == Int {
    func newTest() {
        let array = [[1,2,3],[4,5,6],[7,8,9]]
        let j = Array(array.joined())
        let f = array.flatMap{$0}
    }
}

但这不会编译

struct Test<T> {}

extension Array where Element == Test<Int> {
    func newTestGeneric() {
        let array = [[1,2,3],[4,5,6],[7,8,9]]
        let j = Array(array.joined())
        let f = array.flatMap{$0}
    }
}

在此行 let j = Array(array.joined())

我得到一个错误: Ambiguous reference to member 'joined()'

0 个答案:

没有答案