Created
February 24, 2023 10:12
-
-
Save es-kumagai/8e570979f5f95cc177288e10d977c460 to your computer and use it in GitHub Desktop.
@lococo85327937 そしてそんな総称プロトコル?を型として扱えるのだからそれを「総称型」と呼んでも良いよね⋯Swift 5.8 から P<Element> とも書けるし — みたいに解釈すれば辿りつくものの、些か強引な感じがするのでたぶん間違えました。 #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 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