Created
October 24, 2016 01:16
-
-
Save loganmoseley/4cf2bcf77cd4102a1ceba250ac4197c0 to your computer and use it in GitHub Desktop.
Demonstration of property name collision
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
// Person.swift | |
struct Person { | |
let givenName: String | |
let familyName: String | |
} | |
// SecretAgent.swift | |
protocol SecretAgent { | |
var givenName: String { get } | |
} | |
// Unrelated file | |
extension Person : SecretAgent {} | |
// Point of misunderstanding. | |
func doxxSecretAgent(agent: SecretAgent) { | |
print("Secret Agent's given name: \(agent.givenName)") | |
} | |
// Hope you didn't want that MI6 agent outed. | |
let regularPerson = Person(givenName: "Ian", familyName: "Fleming") | |
doxxSecretAgent(agent: regularPerson) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment