Skip to content

Instantly share code, notes, and snippets.

@es-kumagai
Created January 17, 2023 13:03
Show Gist options
  • Save es-kumagai/48acd48b63609d39f3a17cc9c9266efe to your computer and use it in GitHub Desktop.
Save es-kumagai/48acd48b63609d39f3a17cc9c9266efe to your computer and use it in GitHub Desktop.
いわゆる存在型の展開のうごき、少しばかり癖のある動きを見せる感じね。 #CodePiece
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