Created
June 20, 2017 11:08
-
-
Save takasek/4cbc2b520f261833324dd3b047bf4fba to your computer and use it in GitHub Desktop.
SwiftのArrayのCopy-on-Writeを確認してみる #CodePiece
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
func address(_ o: UnsafeRawPointer) -> String { | |
return String( | |
format: "%p", | |
Int(bitPattern: o) | |
) | |
} | |
let array = [1,2,3] | |
address(array) // "0x600000075ca0" | |
let array2 = array | |
address(array2) // "0x600000075ca0" | |
let array3 = array.map { $0 } | |
address(array3) // "0x600000077a20" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment