Skip to content

Instantly share code, notes, and snippets.

@pofat
Created May 19, 2019 16:20
Show Gist options
  • Save pofat/bf5cbed3fd3b172954dccc1819d47e8f to your computer and use it in GitHub Desktop.
Save pofat/bf5cbed3fd3b172954dccc1819d47e8f to your computer and use it in GitHub Desktop.
protocol MyProcotol {}
struct MyStruct {
let x = 1
let y = 2
}
// What's the difference of following two?
let existentialContainer: MyProtocol = MyStruct()
let structInstance = MyStruct()
print(MemoryLayout.size(ofValue: existentialContainer)) // 40
print(MemoryLayout.size(ofValue: structInstance)) // 16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment