Created
February 8, 2016 19:16
-
-
Save 53ningen/b063c8b545fc97888c47 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 C { func appendC(s: String) -> String } | |
class CImpl: C { | |
private let b: B | |
init(b: B) { self.b = b } //⚡️ CImpl は B のインスタンスを要求する | |
func appendC(s: String) -> String { return b.appendB(s) + "c" } | |
} | |
protocol B { func appendB(s: String) -> String } | |
class BImpl: B { | |
private let a: A | |
init(a: A) { self.a = a } //⚡️ BImpl は A のインスタンスを要求する | |
func appendB(s: String) -> String { return a.appendA(s) + "b" } | |
} | |
protocol A { func appendA(s: String) -> String } | |
class AImpl: A { func appendA(s: String) -> String { return s + "a" } } | |
let c: C = CImpl(b: BImpl(a: AImpl())) // 👈 う〜ん、この・・・。 | |
c.appendC("@") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment