Created
January 17, 2023 13:37
-
-
Save es-kumagai/3390f033243d93a86e91d2e37f0a89e0 to your computer and use it in GitHub Desktop.
先ほどのコードに、インスタンスが具体的にどう扱われているかを窺うコードを追加。内部的な扱いは同じ様子でも、型注釈を明記すると自己準拠性の扱いが変わってくるみたい。 #CodePiece
This file contains 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
something(a) // "some A" | |
something(b) // "some A" | |
something(c) // "some A" | |
something(a as A) // "Any" | |
something(b as A) // "Any" | |
something(c as A) // "Any" | |
MemoryLayout.size(ofValue: a) // 8 | |
MemoryLayout.size(ofValue: b) // 40 | |
MemoryLayout.size(ofValue: c) // 40 | |
MemoryLayout.size(ofValue: a as A) // 40 | |
MemoryLayout.size(ofValue: b as A) // 40 | |
MemoryLayout.size(ofValue: c as A) // 40 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment