Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
protocol LocationProtocol {
// func address() -> String
}
extension LocationProtocol {
}
enum Cities{}
extension Cities {
enum Boston{}
enum Chicago{}
}
extension Cities.Boston {
enum Streets: String, LocationProtocol {
case firstStreet = "First Street"
case secondStreet = "Second Street"
}
enum Avenues:String, LocationProtocol{
case firstAvenue = "First Avenue"
case secondAvenue = "Second Avenue"
}
}
extension Cities.Chicago {
enum Streets: String, LocationProtocol {
case firstStreet = "First Street"
case secondStreet = "Second Street"
}
enum Avenues:String, LocationProtocol{
case firstAvenue = "First Avenue"
case secondAvenue = "Second Avenue"
}
}
var a:LocationProtocol = Cities.Boston.Avenues.firstAvenue
var b:LocationProtocol
b = Cities.Boston.Streets.firstStreet
b = Cities.Chicago.Avenues.secondAvenue
// i like to do this:
// print(b.address)
// Bosten City\nFirst Avenue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.