Skip to content

Instantly share code, notes, and snippets.

@es-kumagai
Created January 10, 2017 15:49
Show Gist options
  • Save es-kumagai/edf258b1b352fb71da33e4a0291924e8 to your computer and use it in GitHub Desktop.
Save es-kumagai/edf258b1b352fb71da33e4a0291924e8 to your computer and use it in GitHub Desktop.
この『プロトコルでtypealiasを使う例』ね。こんなコードを見ながら、プロトコルには型定義をネストできないからプレフィックスをつけざるを得ないけれど…と話していたのでした。 #swift #CodePiece
// 型をプロトコルに入れ子できないので…
enum MyProtocolKind {
}
// 型エイリアスでそれっぽく仕上げる例。
protocol MyProtocol {
typealias Kind = MyProtocolKind
var kind: Kind { get }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment