Skip to content

Instantly share code, notes, and snippets.

@jongwonwoo
Last active March 8, 2016 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jongwonwoo/deacf594772f47aa32a0 to your computer and use it in GitHub Desktop.
Save jongwonwoo/deacf594772f47aa32a0 to your computer and use it in GitHub Desktop.
class Country {
let name:String
var capitalCity:City?
init (name:String, capitalName:String) {
self.name = name
self.capitalCity = City(name: capitalName, country: self)
}
}
class City {
let name:String
unowned let country:Country
init (name:String, country:Country) {
self.name = name
self.country = country
}
}
var country = Country(name: "Korea", capitalName: "Seoul")
print("\(country.capitalCity!.name)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment