Created
May 14, 2019 15:45
-
-
Save creaaa/eec1e5963c2ea97948a000d8c75e97a0 to your computer and use it in GitHub Desktop.
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
import UIKit | |
class HogeClass {} | |
// 意味: このプロトコルに適合させるクラスは、 | |
// 必ずこのクラス(HogeClass)のサブクラスでなくてはならない | |
// ≒ HogeClassを継承しないといけない | |
// (Self == HogeClass とは書けない) | |
protocol HogeProtocol where Self: HogeClass { | |
func hoge() | |
} | |
// | |
class FugaClass: HogeClass, HogeProtocol { | |
func hoge() { print("hoge!") } | |
} | |
// つまりこれがだめ | |
class PuyoClass: HogeProtocol { | |
func hoge() { print("hoge!") } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment