閱讀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小結