Skip to content

Instantly share code, notes, and snippets.

@es-kumagai
Created February 24, 2023 10:12
Show Gist options
  • Save es-kumagai/8e570979f5f95cc177288e10d977c460 to your computer and use it in GitHub Desktop.
Save es-kumagai/8e570979f5f95cc177288e10d977c460 to your computer and use it in GitHub Desktop.
@lococo85327937 そしてそんな総称プロトコル?を型として扱えるのだからそれを「総称型」と呼んでも良いよね⋯Swift 5.8 から P<Element> とも書けるし — みたいに解釈すれば辿りつくものの、些か強引な感じがするのでたぶん間違えました。 #CodePiece
protocol P<Element> {
associatedtype Element
var first: Element? { get }
}
extension Array : P {
}
let x: any P<Int> = [1, 2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment