Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
protocol Named {
func GetName() -> String
}
protocol CasedNamed { // previously "NamedExtension"
func GetLowercaseName() -> String
func GetUppercaseName() -> String
}
extension CasedName where Self: Named {
func GetLowercaseName() -> String {
return self.GetName().lowercaseString
}
func GetUppercaseName() -> String {
return self.GetName().uppercaseString
}
}
extension Int : Named, CasedNamed {
func GetName() -> String {
return "Int"
}
}
1.GetName() // "Int"
1.GetLowercaseName() // "int"
1.GetUppercaseName() // "INT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment