Skip to content

Instantly share code, notes, and snippets.

@muescha
Created January 31, 2017 14:43
Show Gist options
  • Save muescha/b83bfbfe4b0446b280857bbf0d8f9b5c to your computer and use it in GitHub Desktop.
Save muescha/b83bfbfe4b0446b280857bbf0d8f9b5c to your computer and use it in GitHub Desktop.
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