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