附属脚本是访问对象,集合或序列的快捷方式

struct STest{
    let constValue:Int
    subscript(count:Int)->Int{
        return count*constValue
    }
}
let obj = STest(constValue:3)
let res:Int = obj[2]
println("\(res)")

 

相关文章:

  • 2022-12-23
  • 2021-07-12
  • 2022-12-23
  • 2021-04-06
  • 2021-07-04
  • 2021-05-09
  • 2022-02-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-26
  • 2022-12-23
  • 2021-10-21
  • 2022-01-20
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案