Created
January 17, 2023 13:03
-
-
Save es-kumagai/48acd48b63609d39f3a17cc9c9266efe 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
protocol A {} | |
extension Int : A {} | |
func something(_ value: Any) -> String { return "Any" } | |
func something(_ value: some A) -> String { return "some A" } | |
let a: Int = 0 | |
let b: A = 0 | |
let c = a as A | |
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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment