阅读635 返回首页    go 阿里云 go 技术社区[云栖]


Swift 学习之数组(unshare)

import Foundation

println("Hello, World!")

var arr = [1, 2, 3, 4]

var arr1 = arr // share the same elements and do not copy really
arr1.unshare() // really to copy at the time when call unshare method

println(arr1)

arr1[0] = 10
println(arr)
println(arr1)

arr[0] = 20
println(arr) // only one exists, so it is unshare automatically.
println(arr1)

最后更新:2017-04-03 07:57:11

  上一篇:go mpeg文件格式分析
  下一篇:go HTML小结