In C#, there is this great language feature called "explicit interface implementations" that allows you to implement two or more interfaces where the names of the interfaces' methods conflict. It can also make a method do one thing when you call it using an object of the enclosing type, and do another thing when you cast it to the interface type then call the method. I am wondering if there is such a thing in Swift. Does this conflict with any of swift's ideologies?
Basically I want to do something like this:
struct Job: CustomStringConvertible {
var location: String
var description: String
var CustomStringConvertible.description: String {
return "Work Location: \(self.location), description: \(self.description)"
}
}
Job(location: "Foo", description: "Bar").description // "Bar"
(Job(location: "Foo", description: "Bar") as CustomStringConvertible).description // "Work Location: Foo, description: Bar"
I found this on the Internet but I don't think that's relevant because it appears to be about forcing method overriding in child classes.