Last active
August 12, 2021 02:25
-
-
Save AppleCEO/3f6983e42099f96362fa82680a755ca4 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 Coffee { | |
func drink() | |
} | |
struct Americano: Coffee { | |
func drink() { | |
print("아메리카노를 마십니다.") | |
} | |
} | |
struct Programmer { | |
private let coffee: Coffee | |
init(coffee: Coffee) { | |
self.coffee = coffee | |
} | |
func startProgramming() { | |
self.coffee.drink() | |
//... | |
} | |
} | |
let americano = Americano() | |
let programmer = Programmer(coffee: americano) | |
programmer.startProgramming() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment