当前位置 : 主页 > 手机开发 > 其它 >

数组 – 当Element是元组时,Extend Array受限制

来源:互联网 收集:自由互联 发布时间:2021-06-11
当元素是一种元组时,有没有办法扩展数组? public extension Array where Element: (timeZoneName: String, formattedName: String){} This declaration returns 4 errors: Statement cannot begin with a closure expression Braced bloc
当元素是一种元组时,有没有办法扩展数组?

public extension Array where Element: (timeZoneName: String, formattedName: String){

}

This declaration returns 4 errors:

  • Statement cannot begin with a closure expression
  • Braced block statements is an unused closure
  • Expected ‘{‘ in extension
  • Expected identifier for type name

我不知道所显示的错误是否准确.
有任何想法吗?

Swift 3版 appzYourLife的答案:

extension Sequence where Iterator.Element == Tuple2 {
    func foo() {}
}
网友评论