Created
January 16, 2016 15:24
-
-
Save sinsoku/001b99f6c182aa3c4bb5 to your computer and use it in GitHub Desktop.
protocol による多重継承
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 ExternalAccount {} | |
extension ExternalAccount { | |
func save() { | |
print("PATCH http://api.external.com/user") | |
} | |
} | |
protocol DataBaseAccount {} | |
extension DataBaseAccount { | |
func save() { | |
print("Save to Database") | |
} | |
} | |
class User: DataBaseAccount, ExternalAccount {} | |
func updateProfile(user:ExternalAccount) { | |
user.save() | |
} | |
let user = User() | |
updateProfile(user) | |
//=> PATCH http://api.external.com/user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment