[Swift] Value Type의 메모리 주소

Value Type은 cow를 한다면서 왜 Array만 동일 instance에 대해 같은 주소를 반환할까요?

들어가며

의문의 시작

func address(of object: UnsafeRawPointer) -> String{
let address = Int(bitPattern: object)
return String(format: "%p", address)
}

//same memory address
var a = [1, 2, 3]
var b = a
address(of: &a) //0x600002b74c20
address(of: &b) //0x600002b74c20

b.append(2)
address(of: &a) //0x600002b74c20
address(of: &b) //0x600001d509d0
//String
var c = "1b"
var d = c
address(of: &c) //0x10eaec670
address(of: &d) //0x10eaec680

//Dictionary
var e = ["hi" : 3, "bye" : 3]
var f = e
address(of: &e) //0x10eaec690
address(of: &f) //0x10eaec698

//Set
var g: Set = [1, 2]
var h = g
address(of: &g) //0x10eaec6a0
address(of: &h) //0x10eaec6a8

그래서 이유가 뭐라고요??

제 애완동물입니다
따봉 스택오버플로우야 고마워!
func address(of object: UnsafeRawPointer) -> String

얼렁뚱땅 마무리

뭔가 시도해보려고 했던 흔적들..?ㅋㅎ ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ

출처

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store